PHP Syntax

Here we will discuss the basic syntax of writing PHP code. PHP script starts and ends as follows:

  1. PHP NORMAL TAGS :
<?php
   echo “PHP SCRIPT”;
 
?>

OPENING TAG  :  <?php

CLOSING TAG  :  ?>

PHP parser interprets the code in between these tags and everything that is written beyond these tags is simply ignored by the parser.

  • SHORT-ECHO TAGS : short echo tags are used as a shorthand operator of <?php echo. It looks like:

                                                <?=”PHP SCRIPT”?>

  • SHORT-OPEN TAGS : We can also use the short-open tags. The syntax looks like:
<?
   echo “PHP SCRIPT”;
 
?>

However, we need to check the configuration file i.e. php.ini for the status of short-open tags because they could have been disabled via short_open_tag.