11 Dec Run PHP 8 program in XAMPP Server on localhost
PHP 8 release 26th November 2020. With that, the XAMPP support is now live for PHP 8. In this article, we will see how to set up XAMPP for PHP 8. With that, we will also see how to run your first PHP 8 program on localhost Windows 10.
Let’s start with installing XAMPP, and running the first PHP program using XAMPP Server on localhost. The following are the steps:
- Download and Install XAMPP
- Create a new project in XAMPP and add your PHP program
- Open XAMPP and run your first PHP program
Download and Install XAMPP
Step 1: Go to the Apache Friends website and download XAMPP Server (supporting PHP 8). Apache Friends is the official website to download XAMPP:
Step 2: After downloading, install it.
You can install it at any location. We installed XAMPP i.e. C: drive,
1 2 3 |
C:\XAMPP\ |
Create a new project in XAMPP
Step 3: Now, go to the htdocs folder in the Xampp folder and create your project folder.
Here, a folder AmitProject created, as in the below screenshot:
Step 4: Create a new PHP 8 file with the .php extension. We have created a file with the name, demo.php.
Add the following sample code to it. We are printing a line in our PHP 8 file. We have embedded HTML code in the PHP file:
1 2 3 4 5 6 7 8 9 10 11 |
<?php echo "<h2>Demo PHP Project</h2>"; echo "First PHP 8 program on localhost Windows 10<br>"; echo "<em>sample....</em><br>"; echo "<u>First PHP 8 program on VS Code</u>"; ?> |
Open XAMPP and run your first PHP 8 program
Step 5: Go to the start button, and type Xampp Server to open it.
This will open Xampp Server- Control Panel.
After opening it, just click Start on Apache to start the server. If “Status change detected: running” is visible, that means Apache Server ran successfully.
Step 6: Now, go to the Web Browser and type the following and press enter:
1 2 3 |
localhost/AmitProject |
On pressing ENTER, the following will be visible i.e. the location of your project directory with the files in it.
Locate your PHP file demo.php and click on it,
Step 7: After clicking demo.php, just press enter in the address bar, and you can see the output of your first PHP program demo.php:
We saw how to run a PHP 8 program using XAMPP Server on localhost. A step-by-step process to create a new PHP program file and run it to get the output.
Video Tutorial: Run PHP 8 on XAMPP
Here’s the video, explaining the steps shown above,
Note: You do not have to START Apache Server again and again. But, yes, if you “shut down” and “restart” your system, then there is a need of starting the server again.
Hope you liked the tutorial, kindly share it with others.
If you have any queries, then please mention them in the comments section below.
Read More
No Comments