Unlike the html pages that run in the browser (html pages can be built and browser tested directly on the PC without any other program), the php pages run on the server and only the resulting page after preprocessing is displayed in the browser.
So, to test a php page, we need a web server.
In order not to install the Apache web server and the PHP preprocessor separately, there is the free XAMPP application installed in Windows that automatically configures both the Apache web server and the PHP preprocessor, the MySql database, the graphical database management interface: phpMyAdmin , web server for java, Tomcat and others.
First we download the XAMPP.exe application and install it.
Follow the installation instructions:
Select installation packages (it's good to check them all) and click Next
Select the installation directory (it is good to be C: \ xampp) and click Next
Click Finish and the installation is ready.
In the xampp directory, there is an executable file: xampp-control.exe.
Double-click on it and it opens:
From here, we can start and stop web servers and MySql database server. We will start the Apache web server:
The directory from which the Apache server serves the web pages is called htdocs and is found in the xampp directory
In the htdocs directory, there must be a file named index.html (or index.php) that is the home page of any website
Apache web server is turned on, we will open a browser (Chrome, Firefox, IE) and we will type: http: // localhost (or http://127.0.0.1, which is the loopback IP address).
If the Apache web server has been installed correctly, the index.html (found in C: / xampp / htdocs) will open in the browser.
To test now if the Apache web server can also serve PHP pages, we will open Notpad and create a file called phpinfo.php, as in the following figure:
Put this file into the htdocs directory (where the Apache web server serves web pages).
Open a browser (Chrome, Firefox, IE) and type: http: //localhost/phpinfo.php. If the PHP preprocessor is installed correctly, a page with all the information about the installed PHP modules will appear.
In this case everything is OK and we can start working with PHP.
A PHP page may contain HTML code and PHP scripts. A PHP script to be recognized and executed by the preprocessor (in the web server) will be between the tags: <?php and ?>.
Saves the file as sum.php and puts it in the htdocs directory. Open browser and access:
Enter 2 numbers and click the Sum button:
Visit my websites:https://www.jwebsaints.com