Php Syntax


A php script is executed on the server, and the plane HTML result is sent back to the browser.
A php script starts with '<?php' and end with '?>' .

<?php
// all php scripts are written within the opening and closing tag of php
?>

Below is the example of simple php script to display "HELLO INDIA"
<!DOCTYPE html>
<html>
<head><title>expertcoding.com</title>
</head>
<body>
<?php
echo "HELLO INDIA";
?>
</body>
</html>
The php files are  save with '.php' extension . Copy the above code in notepad and save as simple.php.

Now create a new folder myprojrct in www folder of wampserver and pest the simple.php in myproject folder. www folder is located at the place where you have install the wampserver. If you are not able to find the file location just right click on wampserver icon located on desktop and click on property option one popup window will be open in that file location will be mention under the target option.

NOTE :- What ever php file you want to run in browser it must be located in www folder.


Now create new folder over hare and copy the simple.php file in that folder


Now lets see the output in the browser, for that at first run start the wampserver and open the localhost by clicking on wampserver  icon available at tray.


After clicking on the localhost this page will be open in the browser in that you will find a option your project in that option you will all the folder name created on www folder now open your folder by clucking on it.


Now you will all the php file containing in that folder now click on simple.php file to see the output


The above code will display "HELLO INDIA" in browser .