When PHP parses a file, it looks for opening and closing tags, which are <?php and ?> which tell PHP to start and stop interpreting the code between them. Parsing in this manner allows PHP to be embedded in all sorts of different documents, as everything outside of a pair of opening and closing tags is ignored by the PHP parser. 

There are four different pairs of opening and closing tags which can be used in PHP. Two of those, <?php ?> and <script language="php"> </script>, are always available. The other two are short tags and ASP style tags, and can be turned on and off from the php.ini configuration file

 /* standard tags */
<?php 
echo 'if you want to serve PHP code in XHTML or XML documents,
                use these tags'
;

?>

// case insensitive 
<script language="php">
 echo 'some editors (like FrontPage) don\'t
              like processing instructions within these tags'
;

</script>

/* short tags, need short_open_tag enabled in php.ini*/
<?

echo 'this code is within short tags';
 ?>

// asp tags, need asp_tags enabled in php.ini 
<% 
 echo 'You may optionally use ASP-style tags';
%> 



Note: As per coding standards suggest to only use <?php ?> or <?= ?> 

0 comments:

Blog Archive

Total Pageviews

Popular Posts