How to Create A PHP File

Any file containing PHP must have a ".php" file extension, similar to how HTML files, to be identified as HTML files, must have a ".htm" or ".html" file extension.

PHP files can contain HTML in the same file, and still work properly. HTML files, on the other hand, cannot contain a PHP script and still work properly, because the PHP code will be read and displayed as HTML.

Also, while HTML files can be viewed in your browser from your own computer, PHP files must run on a PHP-enabled web server and be viewed with your browser by going to the file's URL (usually the website name + the file name + the file extension, for example: http://www.yourwebsitename.com/test.php).

I would not recommend the use of word processors (ie. Microsoft Word, StarOffice Writer, or Abiword) to save or create PHP files. Text editors such as Notepad or Wordpad on Windows machines, and Kwrite or Kate on Linux machines, are a better option. When saving the file, make sure that you type in the file name and the extension (example: test.php) and that if there is a "Save as Type" dropdown option, that the type is set to "All Files".

(See Example)