·  PHP – Syntax – Delimitators


- Info:
  - This tutorial shows how to embed PHP code into Web Page.

  - Speacial tags (delimitators) are used to define start and end of PHP code.

    This is needed so that Web Browser engine knows which parts of Web Page should be interpreted as PHP.

  - If Web Page has .php extension browser will assueme that <? and <% delimitators define start of PHP code.

    This is similar to .asp web pages where browser assumes that <% delimitator defines start of ASP code.

  - There are 4 different Delimitiation Variants discussed below.


- Default Syntax:

  - This is deafult syntax for labeling code as PHP script.

    <?php echo "This is another PHP example.";?>


- Short-Tags Syntax:

  - Short-Tags Syntax allows you to ommit php from opening delimitator.

  - To use this syntax, you need to enable PHP’s short_open_tag directive in php.ini.

    <? echo "This is another PHP example."; ?>


- Short-Circuit Syntax:

  - Short-Circuit Syntax can be used when you want to quickly escape to and from PHP to output a bit of dynamic text.

    <?="This is another PHP example.";?>

  - This ia equivalent to following line but allows you to ommit echo keyword making your code more readable:

    <? echo "This is another PHP example."; ?>


- Script Syntax:

  - Support for Script Syntax was added because some editors, like FrontPage, had problems with other Syntax forms:

    <script language="php">

      print "This is another PHP example.";



- ASP Style Syntax:

  - ASP Style Syntax was introduced for those comming from ASP background but was removed as of PHP 6:

    <% print "This is another PHP example."; %>


- Example:

  - By using delimitaros you can freely mix PHP and HTML code as this example demonstrates.





          <title><?php echo "Welcome to my Web site!";?></title>




             $date = "July 26, 2007";


          <p>Today's date is <?=$date;?></p>