PHP的四种开始和结束标记
1.CODE<?php echo 'if you want to serve XHTML or XML documents, do like this'; ?>
2.CODE <script language="php">
echo 'some editors (like FrontPage) don\'t
like processing instructions';
</script>
3.CODE<? echo 'this is the simplest, an SGML processing instruction'; ?>
<?= expression ?> This is a shortcut for "<? echo expression ?>"
4.CODE<% echo 'You may optionally use ASP-style tags'; %>
<%= $variable; # This is a shortcut for "<% echo . . ." %>
上例中的 1 和 2 总是可用的,其中 1 是最常用,并建议使用的。
短标记(上例 3)仅在通过 php.ini 配置文件中的指令 short_open_tag 打开后才可用,或者在 PHP 编译时加入了 --enable-short-tags 选项。
注: 如果用 PHP 3 还可以通过 short_tags() 函数激活使用短标记。此方法只适用于 PHP 3!
ASP 风格标记(上例 4)仅在通过 php.ini 配置文件中的指令 asp_tags 打开后才可用。
注: 对 ASP 风格标记的支持是 3.0.4 版添加的。