A PHP script always begins with <?php and ends with ?> syntax. A PHP script can be placed anywhere in the document. On servers with shorthand support you can start a PHP script with <? And end with ?> syntax, but for maximum capabilities, we recommend that you use the standard form ( <?php … ?> ) rather than shorthand form ( <? … ?> ).
A PHP file must have a .php extension. A PHP file normally contains HTML tags and some PHP scripting code. Below, we have an example of a simple PHP script that sends the text “Welcome to GetHow” back to the browser.
<html> <body> <?php echo “Welcome to GetHow”; ?> </body> </html>
Note: Each line in the PHP must end with a semicolon. The semicolon is a separator and is used to distinguish one set of instructions from another.
There are two statements to output the text with PHP i.e. echo and print. In the above example we have used echo statement to output the text “Welcome to GetHow”.
Comments in PHP
In PHP, we use // to make a one line comment and for more than one lines we use /* at beginning and */ at end to make a comment block.
<html> <body> <?php //This is a Statement for GetHow Site /* This is a comment block for more than one line */ ?> </body> </html>
The above all are the basic syntax which are always used while writing a PHP script. We need to understand and practice it more so that, it gets stable on our fingers.