FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!


.html vs .php





Arty
What's the difference between the two file extensions?

I'm under the impression that .php files do the exact same thing as a .html file, but one can read php code and the other can't. Am I right?

If so, why don't more people just save their webpages as .php for default?

Also, if you have more than one index file in a directory (index.html, index.php, index.asp) what will happen?
jylan
Hey Arty,

Yes, only files ending with a php extension can be used for php code, if you saved php code with a html extension it wouldn't work. You could save plain HTML with a PHP extension, I can't think of any real side effects except the server might be slowed down (because it would have to search for PHP code). What would be the point though?

Regarding file extension precedence, as far as I can tell servers differ, and users can manually set their own precedence using a .htaccess file or the like. Godaddy uses this order on their linux servers (http://help.godaddy.com/topic/306/article/60):

Quote:
default.html
default.htm
index.php
index.shtml
index.html
index.htm
home.html
home.htm
index.php5
welcome.html
welcome.htm
RadekPL
Well, PHP is more advanced that html because it can contain server side scrypting and therefore page can be generated dynamically, where html is totally static (what's in the code - that's what is displayed).

However you can use php coding in html pages, but you'll need to tell the server to treat them as php files - all you need to do is change the handling in .htaccess file by adding this:

Code:
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html


That's the best thing to do, when you've got your pages in Google well listed - if you would change the file extension - you would also remove your pages from Google and have to start again...

Html is good if you're starting your experience with webdesign, php is definitely step forward as it gives you more options to control behaviour of your website.
snowboardalliance
The only problem I'd see with .php for just plain .html (besides that it's pointless) is on a server without php installed, I'm not sure that .php file will be treated as .html if the server is not configured for it (I feel like it might prompt for a download on some browsers). I'm not entirely sure though.
Hogwarts
snowboardalliance wrote:
The only problem I'd see with .php for just plain .html (besides that it's pointless) is on a server without php installed, I'm not sure that .php file will be treated as .html if the server is not configured for it (I feel like it might prompt for a download on some browsers). I'm not entirely sure though.


Just as HTML, I believe. The file isn't a binary file (yes, it's stored in binary, but it's not binary that's stored, just a UTF8/etc. representation of characters) and thus will be outputted the same as a .html or .txt file.
shkhanal
PHP and HTM are same up to the limit that both are ascii files. But the difference is vast enough. HTML are static. They can display the page as it was created in design time. PHP can create dynamic pages. That means the programmer will create the framework and behaviour. When the page actually run, it will generate html code and display the different page dependent upon the different states and selections.
Hogwarts
shkhanal wrote:
PHP and HTM are same up to the limit that both are ascii files. But the difference is vast enough. HTML are static. They can display the page as it was created in design time. PHP can create dynamic pages. That means the programmer will create the framework and behaviour. When the page actually run, it will generate html code and display the different page dependent upon the different states and selections.


Eh? What're you talking about? You can run PHP in HTML files >_>
keane
Basically, PHP file extension is used for files that contain PHP code. It also needs a server that supports PHP for the script to be executed.

Also, HTML isn't a programming language like PHP. It's a markup language used to format how text should be displayed.

If you're not using PHP script in your webpage, I don't see the reason why you should save it as .php.
wadja-host
hey there ya'll php is the best and the hottest even asp does not seem to be good enough and the good part bout it its got an unimaginable library of info and i think it will soon be translated into pure plain and simple english well for now what should i say try and learn php if its only html you know about well goto sitepoint and do that

well like u said earlier changing the file name would be just stupid
polly-gone
There is no real advantage to one extension or another. The only real difference is that .php can hold PHP scripts and .html can't. If you aren't using PHP, use either one, it really doesn't matter. What I prefer to do though, is I have a page with absolutely no PHP on it whatsoever, I still save it as .php so that if at a later date, I add PHP to it, I am not going to have to change all the links that lead to it.

-Nick Smile Smile Smile
Related topics
[DESIGNER] - Sites de Código HTML, JAVASCRIPT, PHP(PORUGUÊS)
Frontpage for HTML... ??? for PHP
how can i setup a page break for printer on html using php ?
How to change extension php to html but the php script still
How to parse a HTML with PHP ?
html to php
.html or .php?
how to make old html point to php
learning HTML and PHP
HTML AND PHP CODER NEEDED ASAP
HTML vs PHP pages?
Save as .html or .php
HTML or php Rotation of Advert script needed
Java vs PHP
Reply to topic    Frihost Forum Index -> Webmaster and Internet -> Design Tips

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.