×
☰ See All Chapters

PHP Example

In this tutorial you will learn to create example dynamic web page using PHP. We use XAMPP package installed on windows operating system to run PHP. Refer the previous tutorial How to Install PHP on Windows to prepare environment to run PHP.

Step 1: Create a simple PHP program

PHP programs are saved with .php extension. PHP programs can be written using any editor, such as - Notepad, Notepad++, eclipse, etc. We use Eclipse IDE with PHP Development Tools plugin.  PHP can be embedded within a normal HTML web page. Inside HTML document you can write the PHP statements, as demonstrated in the following example:

<!DOCTYPE HTML>

<html>

<head>

<title>PHP Example</title>

</head>

<body>

<?php

echo 'Hello World!';

?>

</body>

</html>

Save the above program as example.php

Step 2: Copy the PHP file into htdocs folder

PHP file must be saved in the htdocs folder of XAMPP installation. We have installed XAMPP in C drive and path to htdocs folder is C:\xampp\htdocs

php-example-0
 

Step 3: Run the XAMPP server and start the Apache

Launch xampp-control.exe located inside C:\xampp\. It opens control panel window.

php-example-1
 

Start the Apache server

php-example-2
 

Step 4: Check the output

Open https://localhost/example.php from web browser

php-example-3
 

All Chapters
Author