Best file extension to use?

9 replies
  • WEB DESIGN
  • |
I'm starting to think it's .php and just wanted to check if there are any serious disadvantages. All the html parts of a page show up on a desktop site with a .php, just the php includes don't.

If there is any possibility of a site growing, it might be best to just use .php pages. You don't have to use php includes if you don't need them yet, but are ready when you do. You wouldn't have to do redirects from your old .html pages.

Even if the site doesn't grow and you never use a php include, there is still no harm done is there?
#extension #file
  • Profile picture of the author Richard Whyte
    Hi Lloyd

    When you use the .php extension, you are just telling the web server that the page "may" have some php code in it.... Many php pages have lots of HTML code in the and CSS...... It makes no difference if you want to do it that way for future expansion...

    When you are working on your computer and want to see how the pages looks, you may have some issues.... So systems do not now how to view a PHP page. I use xampp (free) on my system so that I can build php based pages on my computer and then use the xampp server to test all functionality. It is web server that you can use on your computer to test things like this out.

    Hope that helps you out.

    Have a Great Day!
    {{ DiscussionBoard.errors[2065210].message }}
    • Profile picture of the author Lloyd Buchinski
      Originally Posted by Richard Whyte View Post

      It makes no difference if you want to do it that way for future expansion.
      Good to know. That's the main part I was wondering about.
      Signature

      Do something spectacular; be fulfilled. Then you can be your own hero. Prem Rawat

      The KimW WSO

      {{ DiscussionBoard.errors[2065516].message }}
  • Profile picture of the author ninal
    I prefer keeping my file extensions as .html and not .php but I still use php includes. I just edit my htaccess file to parse html files as php.
    Signature
    Hello
    {{ DiscussionBoard.errors[2067246].message }}
    • Profile picture of the author Lloyd Buchinski
      Originally Posted by ninal View Post

      I prefer keeping my file extensions as .html and not .php but I still use php includes. I just edit my htaccess file to parse html files as php.
      That's a completely new one to me, but does sound really interesting. That would save redirects if you do want to go from html to php.

      If you had somesite.com/bike.html what would be the .htaccess code to make it act like it was .php?

      Baffled, but really interested
      Signature

      Do something spectacular; be fulfilled. Then you can be your own hero. Prem Rawat

      The KimW WSO

      {{ DiscussionBoard.errors[2070907].message }}
      • Profile picture of the author ninal
        Originally Posted by Lloyd Buchinski View Post

        That's a completely new one to me, but does sound really interesting. That would save redirects if you do want to go from html to php.

        If you had somesite.com/bike.html what would be the .htaccess code to make it act like it was .php?

        Baffled, but really interested
        If you currently have an .htaccess file in your root folder you could just add the line below. If not just create an .htacess file with the code below.

        Code:
        AddHandler application/x-httpd-php5 .html .htm
        or

        Code:
        AddType application/x-httpd-php .htm .html
        First one is the one that works for me, I'm on hostgator.

        It will automatically parse all .htm and .html files as php. And won't affect your other html files (ones without php code).
        Signature
        Hello
        {{ DiscussionBoard.errors[2071117].message }}
        • Profile picture of the author Lloyd Buchinski
          Thanks ninal. That has to be the most interesting thing I've read about .htaccess and I'll have a chance to try this out pretty soon. Neat bit of info.

          I noticed one of your code snips says php, and the other says php5. I assume it would be better not to have the php version number, and this was a moment of inattention? Wondering about that part.

          Php dumbie so don't know if I'm even making sense, or if the 5 refers to something else.
          Signature

          Do something spectacular; be fulfilled. Then you can be your own hero. Prem Rawat

          The KimW WSO

          {{ DiscussionBoard.errors[2071609].message }}
  • Profile picture of the author ninal
    If your hosting is using php 5, the other code won't work. At least that was my experience. I tried using both but ended up using the one with the php5 version. So you'll actually just have to try which one actually works.
    Signature
    Hello
    {{ DiscussionBoard.errors[2073383].message }}
    • Profile picture of the author Lloyd Buchinski
      Thanks, that's good to know. My hosting does use php 5 but sooner or later php 6 is going to come along so that could be a problem. I'd hate to have to come in off the beach or sober up to sort that out.

      I'm not serious about those but rats, it's an extra little complication. It really is a neat solution otherwise. Thanks for the extra info.
      Signature

      Do something spectacular; be fulfilled. Then you can be your own hero. Prem Rawat

      The KimW WSO

      {{ DiscussionBoard.errors[2073688].message }}
  • Profile picture of the author karlhadwen
    Theirs nothing wrong with using '.php', you could always use '.html.php' - tell's the browser and/or server that it's reading a html file with php inside. Not many people tend to use this but if you're worried about which file extension, I'd have to say go with '.php'.
    {{ DiscussionBoard.errors[2073790].message }}

Trending Topics