PHP files need a server to run. You cannot just double-click a .php file.
Option 1: XAMPP (Windows, Mac, Linux)
- Download and install XAMPP (Apache + PHP + MySQL)
- Open the XAMPP Control Panel and Start Apache and MySQL
- Put your files in
C:\xampp\htdocs\myproject - Open
http://localhost/myproject/in the browser
Option 2: Laragon (Windows)
A fast, light alternative. Every folder in www gets a nice URL like http://myproject.test.
Option 3: PHP built-in server
If PHP is installed, run this in your project folder:
php -S localhost:8000
Check your version
php -v
Create info.php with <?php phpinfo(); to see all settings (delete it afterwards — it shows private details).
Code editor
Use VS Code with the PHP Intelephense extension.
Example
Example — Check that PHP works
PHP
<?php
// Save as test.php in htdocs and open http://localhost/test.php
echo 'PHP is working!<br>';
echo 'PHP version: ' . phpversion() . '<br>';
echo 'Server software: ' . $_SERVER['SERVER_SOFTWARE'];
Output: PHP is working! / PHP version: 8.3.x / Server software: Apache/2.4.x (your exact versions may differ).