In this tutorial, we will learn PHP Script Syntax in HTML documents. We can embed PHP Script into standard HTML web pages.
PHP Script Syntax
PHP script starts with <?php and ends with ?>.
We can also use <? to start and ?> to end the PHP script.
PHP Script Syntax Demo
//Sample PHP Code
echo “Hello, This page can run PHP code!”;
<h1>PHP Tutorials </h1>
Save PHP file with a “.php” file extension. For example, This tutorial uses “test.php”. PHP file should be deployed to the server in order to run. The exact path may vary from server to server. On Apache web server it is usually the htdocs folder. Deploy the file to the folder.
We can access the file from the web browser by typing the URL in the address bar.
The string localhost refers to the server running on your own machine. We can also refer to the local server is by using the loopback IP address: 127.0.0.1
The server runs on the default HTTP port 80. Incase the server runs on a different port we can append the port to the address. For example, if the server runs on 8080 port, we can access the URL as:
PHP Tutorials on this website:
More Information on PHP