PHP Syntax

This tutorial gives an idea of the basic syntax of PHP. But, first, let's see what PHP syntax is.

In general, PHP pages are HTML pages with PHP commands embedded in them. It is in contrast to several other dynamic web page solutions, which are scripts that generate HTML. After processing PHP commands, the web server sends their output (and any HTML from the file) to the browser.

 

Basic PHP Syntax

You can place a PHP script anywhere in the document. A PHP script begins with <?php and ends with ?>.

<?php
// PHP code or content goes here
?>

".php" is the default extension for PHP files.

 

Your First program in PHP.

<html>
 <head>
 <title>Look Out World</title>
 </head>

 <body>
 <?php echo "Hello, world!"; ?>
 </body>
</html>

 

Note-  PHP statements always end with a semicolon (;).