Creating a PHP File

To create a PHP file you need to use a text editor, or a PHP editor as we’re going to be developing in PHP. There are various editors available, the editor I’m most familiar with is Notepad++ which is an open source text and source code editor, however I would also recommend VS Code.

Naming the File

It’s important that the file you create has a .php file extension. This should be lowercase - you should check that you don’t have any prefixing or trailing file type extensions for example .php.txt.

The best way to ensure that you save your file correctly in Notepad++ is to select the PHP file type from the dropdown menu in the save dialog.

image-20210104102430370

You should also ensure that your filename contains no spaces and follows regular file naming conventions. See the file name conventions section for more details.

In this case I’m creating my first PHP page so I’ve called it ‘index.php’. The index file is the first file our web server will look for and will essentially be displayed as the homepage of the website. This is usually the case for Apache and Nginx web servers.