Using Notepad or TextEdit for PHP

How to Create and Save PHP in Windows and macOS

PHP Code on a screen shot with shallow depth of field
A screenshot PHP code. Getty Images/Scott-Cartwright

You don't need any fancy programs to work with the PHP programming language. PHP code is written in plain text. All Windows computers including those running Windows 10 come with a program called Notepad that creates and modifies plain-text documents.

Saving PHP Documents

In your text editor, just save the PHP source code with a PHP extension. Windows may or may not recognize PHP as a valid system file type, but it doesn't matter. You generally don't want Windows to attempt to execute a PHP script. You could, however, associate PHP as a file type that your favorite text editor manages, so double-clicking a PHP file will open it in that editor.

Media Files Saved as PHP

Some browser plugins that download media from web pages will incorrectly capture the media file's correct extension. The file will save with the correct name, but with a PHP extension. This glitch occurs only occasionally and stems from the media file sourcing from a PHP-enabled page. All you need to do is change the PHP extension to something like MP4. Video-playback programs like VLC accept the MP4 extension without complaining, even if the underlying video type is something else.

Writing PHP

Unlike some programming and scripting languages, PHP is not sensitive to indentations. Therefore, any indentations you make to your PHP code to aid your readibility are fine.

Other Programs to Edit PHP Files

Notepad is simple, but it's not the only choice. Mac users can use TextEdit. Hardcore programmers (usually, on Linux) rely on environments like Emacs or Vim.

Better than using a text editor — which, by design, just edits text, without additional functionality — is to use a text editor optimized for coding. On the Windows platform, programs like Visual Studio Code, BB Edit, UltraEdit, and Notepad++ not only edit your text but can lint (analyze for errors) and format your code with special colors and related visual cues.