Skip to Content

How to run a PHP file in Chrome in 2023

How to run a PHP file in Chrome in 2023

PHP is a server-side scripting language. Unlike static HTML pages, it is not possible to view the web page created by a PHP script by opening the file in Chrome.

PHP scripts must be saved on a web server with PHP services and must then be located by entering the web address in the address bar of the Chrome browser, or by following a link in the same location.


How to run a PHP file in Chrome in 2023

To run a PHP file in Chrome, here are a couple of solutions:

Solution: Use XAMPP software

XAMPP is free software released under the GNU General Public License, and thanks to it, you will be able to view your dynamic pages locally created in PHP language.

This software also provides PhpMyAdmin, a very useful application for the management of your databases, which can then be interfaced with your PHP pages.


Step-by-step instructions:

1. Download and install XAMPP – The installation is quite simple and straightforward. In this regard, I recommend leaving all the default and recommended settings.


2. Starting XAMPPOnce installed, you need to open the XAMPP Control Panel.

Starting Xampp control Panel

Starting XAMPP Control Panel


Once started, you will have a screen like this in front of you.


How to run a PHP file: Xampp Control Panel View

How to run a PHP file: XAMPP Control Panel View


To view your PHP pages, you need to click on “Start” next to the Apache and MySQL modules (MySQL is useful if you need to take data from your database).


Start Apache and MySQL in XAMPP

Start Apache and MySQL in XAMPP


The operation will have been carried out successfully if the two modules have been started. And you will notice it if you see a situation like this in the Control Panel.


Apache and MySQL running in XAMPP

Apache and MySQL running in XAMPP


3. Create your PHP page. If you haven’t already, create a PHP page by opening a new file in an IDE (integrated development environment) text editor of your choice (such as SublimeText) and save it using the .php extension. Use the following outline structure:


<head> </head> 
<?php echo "Page content"; 


4. Place the PHP file on the server. Whether you are using a server on your computer or the web. Put the PHP file in the location you want it to be accessible from.

For XAMPP, you will need to put the PHP file in the .htdocs folder.

For web servers, you will need to make an FTP connection using a program like FileZilla or your web host control panel.


5. Find the path to your PHP page in your Chrome browser. Type the address in the Chrome address bar.

If you placed the file in the root directory. The page address will have the following structure, using its domain and file name:

If the PHP file is in a subdirectory, its location will have the following structure.

If the PHP file is running on a local server installed on your computer. The file location will have the following structure. http: //localhost/yourfile.php

6. Check the functionality of the page. The details of how you test your PHP will depend on its purpose.

Check first that the content is all that appears and is structured correctly in HTML.

If necessary, you can view the source of the HTML page using the browser menu. If the page contains user controls, test these thoroughly to ensure they work as you need.



As you have learned, running a PHP file directly in the Chrome browser is not possible. However, there is great software such as XAMPP that will help you to run and test your PHP file.

I hope this tutorial is a good starting point explaining how to run a PHP file in Chrome, or at least explaining how it can be done.

Happy coding!