Open PHP file in the browser - how it works
To open a PHP file in the browser, you need a server environment. We'll show you how to get a virtual server up and running on your machine and how to output PHP code without installing a server environment.
Open PHP file with XAMPP
With XAMPP's Apache server, you can open PHP files locally on your computer or Mac:
- Download XAMPP and install the software. We will show you how to set up XAMPP correctly afterwards in another article.
- If you have installed XAMPP, you have to open the Application Manager and start the "Apache Web Server" under "Manage Servers".
- Now place your PHP file in the "htdocs" folder, which you can find in the installation folder of XAMPP.
- To finally access your file, start your browser and enter "Localhost / file name.php" in the address line. Instead of "filename" insert the name of your PHP file.
Test PHP command online: Open PHP directly in the browser without installation
On the page phpbounce.aws.af.cm you can type PHP commands directly into the browser and have the result output online.
- Copy a PHP command into the upper text field.
- Click the "Execute!" Button.
- In the lower window you get the output of the PHP command.
In the next practical tip, you will learn how to insert an image in PHP.