Why use PHP?
Every page on this site — and on all our sister sites — is written in HTML, CSS and PHP. PHP runs on your host’s server and builds each page before it’s sent to the visitor, so you can share one header and footer across every page, send emails from a contact form and read from a database.
According to W3Techs’ ongoing survey, PHP runs around 70% of all websites whose server-side language can be identified — including every WordPress site. With such a massive following, it would be silly to steer you anywhere else: every cheap host supports it, and every question you’ll ever have has been answered online.
What makes a good editor
- Colours HTML, CSS, JavaScript and PHP (syntax highlighting)
- Warns you about mistakes as you type
- Auto-completes tags, functions and file names
- Search and replace across the whole site
- Can upload to your host (SFTP) or works with Git
- Formats your code neatly with one key press
Never use a word processor such as Word to write code: it adds hidden formatting and “smart” quotes that break your pages.
Code editors compared
| Editor | Cost | Runs on | Why choose it |
|---|---|---|---|
| Visual Studio Code | Free | Windows, Mac, Linux | Our pick for beginners. Add a PHP extension such as Intelephense for error checking and auto-complete. Huge choice of free extensions, built-in Git and terminal. |
| Notepad++ | Free | Windows | Small, fast and simple. Colours your code, but doesn’t check PHP as deeply. |
| Sublime Text | Free to try; licence for continued use | Windows, Mac, Linux | Very fast, even with huge files, and a one-off licence rather than a subscription. |
| PhpStorm | Subscription after a 30-day trial (free for students and teachers) | Windows, Mac, Linux | The most complete PHP tool: deep code checks, debugging and database tools. More than a small site needs. |
Whichever you choose, set it to save files as UTF-8, so characters such as £ and curly quotes display correctly.
The rest of your toolkit
| Tool | What it’s for | Free options |
|---|---|---|
| File transfer | Copying files from your computer to your host | cPanel’s File Manager, an FTP program such as FileZilla or WinSCP, or your editor itself — VS Code and Dreamweaver can upload as you save. See FTP program or code editor? |
| Local test server | Trying pages on your own computer before they go live | PHP’s built-in server (below), XAMPP, Laragon |
| Browser developer tools | Inspecting a page, testing on phone-sized screens, finding errors | Built into Chrome, Edge, Firefox and Safari (press F12) |
| Version control | Keeping every version of your site so you can undo mistakes | Git, with GitHub or GitLab |
If PHP is installed on your computer, you can preview a site folder without installing anything else. Open a terminal in the folder and run:
php -S localhost:8000Then visit http://localhost:8000 in your browser. Press Ctrl + C to stop it.
Ready to write your first page? See the structure of a web page for a complete, modern template you can copy.
Questions about code editors and PHP
What is the best free editor for PHP?
For most people, Visual Studio Code. It is free on Windows, Mac and Linux, and with a PHP extension such as Intelephense it checks your code, completes function names and jumps between files. Notepad++ is a lighter free choice on Windows.
Is PhpStorm worth paying for?
PhpStorm is excellent for large PHP projects, but it is a paid subscription after a 30-day trial (students and teachers can get it free). For a small website, a free editor does everything you need.
Do I need to install PHP on my computer?
No. You can edit files on your computer and upload them to your host to test them. Installing PHP, or a bundle such as XAMPP or Laragon, just lets you preview pages before they go live.
Can I edit my website directly in cPanel?
Yes. cPanel’s File Manager has a built-in code editor, which is fine for a quick fix. For anything more, edit on your computer, keep a copy and upload the changed files, so a typo never leaves you without a working version.
Should I learn HTML before PHP?
Yes. PHP builds HTML pages, so learn HTML and CSS first. You can then add PHP a little at a time, starting with a shared header and footer.