Install PHP and Run Your First Script
Install PHP, check versions, and run your first PHP file locally step by step.
Let’s set up PHP so you can run code on your own machine. ## Step 1: Install PHP ### On Windows Download from php.net and add PHP to PATH. ### On macOS (Homebrew) ```bash brew install php ``` ### On Linux ```bash sudo apt install php ``` ## Step 2: Check installation ```bash php -v ``` You should see the PHP version. ## Step 3: Create your first file Create a file: `index.php` ```php <?php echo "My first PHP app!"; ?> ``` ## Step 4: Run it From terminal: ```bash php index.php ``` Or using built-in server: ```bash php -S localhost:8000 ``` Then open: `http://localhost:8000` > Next: PHP syntax basics and how PHP mixes with HTML.