Difference between PHP and PHP5 file extensions

The file extension tells the web server which version of PHP to use. Some web servers are set up so that PHP 4 is the default, and you have to use .php5 to tell it to use PHP 5. More and more web servers these days are set up so that .php defaults to PHP 5, and the .php5 extension doesn't do anything extra.

In fact, if you have control over the web server you should be able to configure the mapping between file extensions and PHP versions whichever way you want. On shared hosting providers the mapping can't be changed without affecting other users of the same server.

If the .php extension gives you the version of PHP that you require, then go for it. It's best to keep it consistent across your entire project, however.


It's usually done so they can run two version of the PHP interpreter on the server and the Apache to parse .php5 files with the PHP 5.x interpreter and .php files with an older PHP 4.x interpreter.

You'd have to check your Apache config to see if this is the case. If this is the case you'd then have to change the config to parse .php files through the PHP 5.x interpreter before renaming the file extension.

Then run the app through it's paces keeping an eye on the error log for new error/notices. I had a similiar experience and found out I had to convert all instance of ereg (which is deprecated in PHP 5) to preg_match.

Tags:

Php