How to Run PHP Programs in XAMPP Example?
Nov 24, 2021
Hi Guys,
How to run PHP programs in XAMPP PHP is a popular backend programming language. PHP programs can be written on any editor, such as - Notepad, Notepad++, Dreamweaver, etc. These programs save with .php extension, i.e., filename.php inside the htdocs folder.
Generally, a PHP file contains HTML tags and some PHP scripting code.
It is very easy to create a simple PHP example.
To do so, create a file and write HTML tags + PHP code and save this file with .php extension.
As I'm using window, and my XAMPP server is installed in D drive. So, the path for the htdocs directory will be "D:\xampp\htdocs".
PHP program runs on a web browser such as - Chrome, Internet Explorer, Firefox, etc. Below some steps are given to run the PHP programs.
Let's start example following command.
Step 1 : Create a simple PHP program like hello world.
<?php
echo "Hello World!";
?>
Step 2 : Save the file with hello.php name in the htdocs folder, which resides inside the xampp folder.
Note: PHP program must be saved in the htdocs folder, which resides inside the xampp folder, where you installed the XAMPP. Otherwise it will generate an error - Object not found.
Step 3 : Run the XAMPP server and start the Apache and MySQL.
Step 4 : Now, open the web browser and type localhost http://localhost/hello.php on your browser window.
Step 5 : The output for the above hello.php program will be shown as the screenshot below:
Output :
- How To Use Php Conditional Statement Example
- How to Check if String Contains Regex in PHP?
- PHP Array_column() Function Example
- PHP Generate List of Random Numbers Between 0 and 100 Example
- How to User Login with Facebook in PHP?
- How to Explode Every Character into Array Using PHP Example?
- PHP Form Validation Tutorial
- PHP Convert XML to JSON Example