8 lessons · PHP 8.5 runs in your browser · No account
Learn PHP
PHP is an open source scripting language used mostly to build websites, and its code can sit inside an HTML page. Chapter 1 teaches you to print text, store values in variables and work with strings and numbers.
$name = "World";
echo "Hello, {$name}!\n";Hello, World!
Every lesson looks like this. Edit the code, press Run, read the real output.
What you'll learn
1Getting started7 lessons
- 1. Hello World (finished)Write Hello World in PHP and run it online or with php hello.php, php -S or XAMPP. Learn when to leave out ?> and fix the errors beginners hit.
- 2. echo and print (finished)Output text and HTML with echo and print in PHP. Compare them, add new lines with \n, PHP_EOL or <br>, and see why echo false prints nothing.
- 3. Variables and constants (finished)Create PHP variables with a $ name, follow the naming rules and change values, then store fixed values in constants with const or define().
- 4. Data types (finished)PHP has nine built-in data types. Check a value's type with var_dump(), convert it with a cast such as (int) and see the casts PHP 8.5 deprecated.
- 5. Strings (finished)Create PHP strings with single or double quotes, put variables inside them, join them with a dot, and use escape sequences, heredoc and strlen().
- 6. Numbers and math (finished)Learn PHP's arithmetic operators, when / returns a float, why 0.1 + 0.2 isn't exactly 0.3, and how round() and number_format() handle decimals.
- 7. Comments (finished)PHP comments use //, # or /* */. Learn to comment out lines safely, add DocBlocks, and avoid the ?>, #[ and nested comment traps.
Frequently asked questions
What is PHP used for?
PHP is used mainly for server-side web development. It collects form data, builds pages from databases and sends cookies. It also runs command-line scripts and can output JSON, XML, images and PDF files.
What does PHP stand for?
PHP stands for PHP: Hypertext Preprocessor, a recursive acronym. Rasmus Lerdorf created PHP in 1994 as Personal Home Page Tools, a set of programs written in C. The current meaning dates from PHP 3.0, announced in June 1998.
Is PHP outdated?
No, PHP is still maintained. PHP 8.6.0 came out on November 19, 2026, with bug fixes until December 31, 2028, and critical security fixes until December 31, 2030.
Is PHP hard to learn?
PHP is not especially hard to start with. A complete first script fits on one line. When an error in your code stops PHP, the message names the file and the line where PHP stopped, which shows you where to look first.
Is PHP a frontend or backend language?
PHP is mainly a backend language. It runs on the server, and the browser receives only the result of running the script, usually HTML. Client-side JavaScript, by contrast, runs inside the page itself.
What is the difference between PHP and HTML?
Unlike HTML, PHP is a programming language. HTML is markup, and by default the server sends a .html file unchanged on every request. In a .php file, PHP code mixed into the HTML runs on the server and can build a different page each time, for example from form data or a database.
Do I need to install PHP to take this course?
No, every runnable example and exercise in the PHP course works on the page with nothing to install. The lesson pages run PHP 8.5.12 and point out any output that differs in PHP 8.6. The Installing PHP lesson shows how to set up PHP on Windows, macOS and Linux.























