Because PHP runs on a server, you need something acting as a server to try it out — but that doesn't mean installing complicated software. PHP ships with a small built-in development server that's more than enough for learning and local testing.
Download PHP from php.net/downloads (Windows) or install it through your system's package manager (brew install php on macOS, apt install php on most Linux distributions). Once it's installed, confirm it worked by checking the version from a terminal:
php --versionIf that prints a version number, PHP is ready to use.
Create a file named index.php with the following content:
<?php
echo "Hello, world!";
?>Every PHP script needs to be inside <?php ... ?> tags — that's how the server knows where PHP code starts and stops (you'll look at this properly in the next lesson). echo is the command that outputs text.
From the same folder as index.php, run:
php -S localhost:8000Then open http://localhost:8000 in a browser. You should see Hello, world! — that text was generated by PHP running on your machine, not typed directly into an HTML file.
Built-in server = local only
The built-in server (php -S) is perfect for learning and local development, but it's not meant for a real, public website — a live site needs a proper web server like Apache or Nginx alongside PHP. That's a deployment topic, not something you need to worry about while learning the language itself.
With PHP actually running, the next lesson looks at the syntax rules you just used — the <?php ?> tags, statements, and comments — in proper detail.