SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Aug 2007
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with php extension

    I am currently learning to integrate php into my website, which is hosted on earthlink. They support php, but I've noticed that I have to save my files as .php5 to get them to work. If I just save them as .php they don't run.

    My concern, looking ahead, is that all my scripts will be null and void when php6 comes out because eventually the browswers won't read the php5 extension. Are my fears justified or am I being overly anxious? If my fears are justified, is there anything I can do to make my life easier in the future? Thanks.

  2. #2
    $books++ == true matsko's Avatar
    Join Date
    Sep 2004
    Location
    Toronto
    Posts
    795
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP6 won't come out for at least a year and when that happens it will be beta for atleast half a year. It won't take over all the other php versions for at least three years. PHP5 came out three years ago and NOW, finally, at the end of the year PHP4 will be obsolete. So I wouldn't really worry about php5 becoming null.
    I can't believe I ate the whole thing

  3. #3
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could define a variable within your code for use when you link, or refer to other PHP files.
    That way, down the track, you can change the extension your app looks for in a single location. (see below)

    You'll still need to physically rename all files, but there are many batch file renaming tools that'd allow this.

    PHP Code:
    <?php
    $PHP_EXT 
    'php5'//current file extension.

    echo "<a href='somefile.{$PHP_EXT}'>Go to another page</a>";
    require (
    "classes/myclass.{$PHP_EXT}");  //require a PHP file

    ?>
    <form action="process_this.<?php echo $PHP_EXT;?>" method="post">
    I am a form
    </form>

  4. #4
    SitePoint Guru brent5392's Avatar
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    636
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or, if your on apache, you could use .htaccess to return the .php5 files for ever .php request. This would mean when you ever move your site, you would just have to rename and wouldnt have to update your files.

    Code:
    RewriteEngine On
    RewriteBase /
    RewriteRule $(.+).php $1.php5 [NC,L]
    I think the above will work, but dont hold me to it

    Im not completely sure, but i think there is a way you can set php to parse .php files through .htaccess? Could anyone back me up here?
    PHP | MySQL | (X)HTML | CSS

  5. #5
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    good idea brent, but I think your rewrite rule needs a bit of fine tuning. The $ should probably match the end of the URL (except for query parameters) and the .php would need to be escaped as \.php

    .htaccess would be a better solution than what I proposed


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •