Installing PHP
You need PHP and a web server to run PHP scripts. XAMPP or MAMP provide PHP, Apache, and MySQL in one package.
Example
# Check if PHP is installed
php --version
# macOS (with Homebrew)
brew install php
# Ubuntu/Debian
sudo apt install php php-mysql php-cli
# Windows: Download XAMPP from apachefriends.org
# Run PHP's built-in development server
php -S localhost:8000
# Run a PHP file from command line
php script.php PHP Configuration
PHP's behavior is controlled by the php.ini file. You can also set configuration at runtime.
Example
<?php
// View PHP configuration
phpinfo();
// Common php.ini settings:
// display_errors = On (development)
// display_errors = Off (production)
// error_reporting = E_ALL
// max_execution_time = 30
// memory_limit = 128M
// upload_max_filesize = 2M
// Set at runtime
ini_set('display_errors', 1);
error_reporting(E_ALL);
?> 