A small course in 8 short lessons on the basics of PHP, the language that runs many websites on the server. You learn echo, variables, numbers, choices with if, loops, functions, arrays and how to handle input from a visitor safely. PHP runs on a server, so this course checks your code instead of running it.
PHP runs on a web server, not in your browser. So this course does not run your code: it checks that it contains what the task asks for, and shows what a server would print. A typing mistake in your code is not detected.
0 of 8 lessons done. Your progress is saved in this browser.
1. Say something with echo
PHP is a language that runs on a web server and builds a page before it is sent to the visitor. PHP code goes between <?php and ?>. echo prints text. Text goes between quotes and every line ends with a semicolon.
Your task: Print a text of your own with echo.
Your code stays in this browser. It is not saved or sent anywhere.
Features
- 8 short lessons, from echo to safe input from a visitor
- Check my answer, a hint and the model answer for every lesson
- Shows what the model answer prints on a server
- Your progress is remembered in this browser
How to use Learn PHP
- Read the lesson and the task.
- Write your code in the editor.
- Press Check my answer. Use the hint or the answer if you are stuck.
- Go to the next lesson.
Frequently asked questions
Does this course run my PHP code?
No. PHP runs on a server, not in your browser. The course uses patterns to check that your code contains what the task asks for, and shows what the model answer would print on a server. A typing mistake in your code is not detected.
How can I run PHP myself?
You need PHP on your computer or a web host that supports PHP. Many hosting plans include it. Put your code in a file with the .php extension and open it through the server.
Should I learn HTML first?
It helps. PHP often builds HTML, and knowing tags and pages makes the lessons clearer. There is an HTML and CSS course on this site.
Is my code saved?
Only which lessons you finished is saved, in this browser. The code you type is not stored or sent anywhere.