Monday, 20 May 2013

php syntax


PHP Syntax

    Syntax -

        Syntax - The rules that must be followed to write properly structured code.
    PHP's syntax and semantics are similar to most other programming languages (C, Java, Perl) with the addition that all PHP code is contained with a tag, of sorts.

    PHP opening and closing Tags syntax

    There are four different pairs of opening and closing tags which can be used in php. Here is the list of tags.
  • Default syntax
  • Short open Tags
  • HTML Script Tags
  • ASP Style Tags
  • Default Syntax

    The default syntax starts with " <?php " and ends with " ?> "
    Example :

    <?php "this is a default tag."; ?> ?>

    Short open Tags

    The short tags starts with " <? " and ends with " ?> ". Short style tags are only available when they are enabled in php.ini configuration file on servers.
    Example :

    <?php "this short open tag"; ?>

    HTML Script Tags

    HTML script tags look like this :
    Example :

    <script type='php'>  echo 'This is HTML script tags.'; </script>

    ASP Style Tags

    The ASP style tags starts with " <% " and ends with " %> ". ASP style tags are only available when they are enabled in php.ini configuration file on servers.
    Example :

    <% echo 'This is asp style tags.'; <%>

No comments:

Post a Comment