First, the start and end tags of the PHP code
1,<?php and?>// Focus
2,<script language= "PHP" > and </script>
3,<? and?>//short label mode, need to open php.ini short_open_tag option
4,<% and%>//asp mode, need to turn on php.ini asp_tags option
The above four kinds of PHP code tags, only recommended 1, the remaining three are just to let you know, to avoid affecting your reading other people's code.
11. <?phpEcho' If you want to serve XHTML or XML documents, does like this ';?>//Mark 12 32. <script language= "PHP" >//Mark 24 Echo‘some editors (like FrontPage) don\ ' t5Like processing instructions ';6</script>7 83. <?Echo' This was the simplest, an SGML processing instruction ';?>//Mark 39<?= expression?> This is a shortcut for"<? echo Expression?> "Ten One4. <%Echo' Optionally use Asp-style tags '; %>//Mark 4 A<%=$variable;#This was a shortcut for "<% echo ..."%>
Second, in addition to the simple Echo method, you can also use all of PHP's process statements and function calls
1<?PHP2 if($expression) {3?>4<strong>this istrue.</strong>5<?PHP6}Else {7?>8<strong>this isfalse.</strong>9<?PHPTen } One?> A -<?PHP - for($i= 0;$i<10;$i++){ the?> -i = <?phpEcho $i;? > <br/> -<?PHP - } +?>
Three, the last?> can be omitted, when a PHP file is very long, very useful
1 <? PHP 2 3 // ... Omitted here 10000 lines 4echo "End without mark are also possible"; 5 // no matter how many <?php appear before, only the last?> can be omitted, the rest must appear in pairs
php-Language Reference-Basic syntax 3.1