How to Learn PHP as a Beginner: A Simple Plan
Updated November 2026
Written by the Toolpuffin team. Tools in this guide are tested in the browser.
PHP is a language that runs on a web server and builds pages before they are sent to the visitor. Many websites, including WordPress sites, are built with it. This guide gives a simple order to learn the basics in, explains how to run PHP yourself and links to a free course to practise with.
What PHP does
A web page in the browser is HTML, CSS and sometimes JavaScript. PHP works one step earlier, on the server: it can read a form, look something up and then build the HTML that is sent to the visitor. The visitor never sees the PHP code, only its result. That is also why PHP does not run inside a web page the way JavaScript does.
What to learn first
- Output: printing text with echo.
- Variables, which start with a dollar sign.
- Numbers, text and joining text with a dot.
- Choices with if and else.
- Loops that repeat code.
- Functions: code with a name that you can use again.
- Arrays: lists of values.
- Input from a visitor, and how to print it safely with htmlspecialchars.
The last step matters most for real sites. Text that a visitor sends can contain code, so it must never be printed to the page as it is.
How to practise
The free course has 8 short lessons in this order. Because PHP needs a server, the course does not run your code. It checks that your code contains what the task asks for and shows what a server would print.
To run PHP for real, install PHP on your computer, put your code in a file that ends in .php and start PHP's built-in test server in that folder. You can also use a web host that supports PHP.
Common mistakes
- Forgetting the semicolon at the end of a line.
- Forgetting the dollar sign in front of a variable name.
- Using single quotes when you want a variable inside the text. Variables are only filled in inside double quotes.
- Mixing up = and ==. A single = gives a value to a variable. Two == compare two values.
- Printing what a visitor sends without htmlspecialchars.
What to learn next
After the basics, learn how to process a form, how to store data in a database and how to keep that safe with prepared statements. It also helps to know some HTML and CSS, because PHP usually builds HTML.