To run PHP on your computer, you need a local server environment. The easiest way is using XAMPP, which includes Apache, MySQL, and PHP in one package.
Visit the official Apache Friends website and download the installer for your operating system (Windows, Linux, or macOS).
Open the downloaded file. During installation, make sure the following components are selected:
After installation, open the XAMPP Control Panel and click the "Start" button next to Apache and MySQL. When they turn green, your server is live!
Go to the C:\xampp\htdocs folder and create a new file named test.php. Paste the following code inside: