Before you can run PHP, you need a server that speaks PHP. Your computer doesn't understand PHP by default โ you need something to interpret that code. That's where a local server setup comes in.
The easiest way to get started on Windows is XAMPP. It's a single installer that gives you Apache (the web server), PHP, and MySQL all bundled together. Download it from apachefriends.org, install it, and you're most of the way there. On Windows, WAMP is another solid option โ same idea, Windows-focused.
Once installed, start the Apache server, create a file called index.php in the web root folder (usually C:\xampp\htdocs or C:\wamp64\www), and you're ready to code.
Your First PHP File
PHP files use the .php extension. You can write plain HTML in them and drop in PHP wherever you need it. PHP code lives inside special tags that tell the server: "hey, run this part as PHP."
<?php
echo "Hello from PHP!";
?>
Try it Yourself โ
The <?php opens a PHP block and ?> closes it. Everything between those tags is interpreted as PHP code. Anything outside is sent directly to the browser as HTML.
Setting Up Without Installing Anything
Don't want to install software? No problem. You can use an online PHP editor. They let you write PHP code in your browser and see the output instantly. Sites like PHP Sandbox, 3v4l.org, or the try-it editors on this very site let you run PHP without installing a thing.
For this tutorial series, I've included try-it buttons that take you straight to a working PHP environment. You can experiment, break things, and learn without touching your computer's file system. But eventually, you'll want a local setup so you can build real projects.
Checking Your PHP Installation
If you have PHP installed locally, you can check the version by opening a terminal and typing:
php -v
This should show you the PHP version number. If you see an error, PHP isn't in your system PATH. On XAMPP, you can find PHP at C:\xampp\php\php.exe. On WAMP, it's in the WAMP installation folder.
Once you see that version number, you're officially a PHP developer. Welcome.