PHP Syntax – How to Write First Server Side Script in PHP In Easy Way [Full Tutorail]
Description:
Having installed and configured PHP, it is now time to put it to the test. In this post, you will create your first script and spend a little time analyzing its syntax. Before start discussion defines localhost. How to Write First Server Side Script in PHP In Easy Way.
How to Write First Server Side Script in PHP In Easy Way
What is Localhost?
The localhost is the default name describing the local computer address also known as the loopback address. For example, typing: ping localhost would ping the local IP address of 127.0.0.1 (the loopback address). When setting up a web server or software on a web server, 127.0.0.1 is used to point the software to the local machine. The local loopback mechanism is useful for testing web/software during development.
127.0.0.1 localhost
How to Write First Server Side Script in PHP In Easy Way
Step 01: Open Xampp Control Panel and start Apache & MySQL Server.
Step 02: Open Xampp Installation Folder and Find htdocs folder:
c:/xampp/htdocs
Step 03: Create new folder with name of demo in htdocs folder.
Step 04: Open your favorite text editor like PhpStorm, Adobe Dreamweaver, Sublime Text, Brackets and Notepad++.
Step 05: Create first php file (index.php) and write first PHP code and save in C:\XAMPP\htdocs\demo.
A PHP script starts with <?php and ends with ?>:
<?php
// PHP code goes here
?>
The default file extension for PHP files is “.php”.
PHP statements end with a semicolon (;).
Example 01:
Step 06: Open your browser (http://localhost/demo).
Example 02:
Thank you for visit our blog! Please Share 🙂