gongzhonghao.png
扫码关注我们
最新赞助活动温馨提示:自愿赞助服务器费用,学生和没有工作的整站资源免费下载!
头像

php指令分隔符

来源:http://erdangjiade.com/topic/3210.html 你好,世界。 2017-09-25 22:42浏览(14)

同 C 或 Perl 一样,PHP 需要在每个语句后用分号结束指令。一段 PHP 代码中的结束标记隐含表示了一个分号;在一个 PHP 代码段中的最后一行可以不用分号结束。如果后面还有新行,则代码段的结束标记包含了行结束。

<?php
     echo  "This is a test" ;
?>
<?php  echo  "This is a test"  ?>
<?php  echo  'We omitted the last closing tag' ;

文件末尾的 PHP 代码段结束标记可以不要,有些情况下当使用 include 或者 require 时省略掉会更好些,这样不期望的空白符就不会出现在文件末尾,之后仍然可以输出响应标头。在使用输出缓冲时也很便利,就不会看到由包含文件生成的不期望的空白符。

束标记(?>)同样隐含语句的结束,因此下面的代码是等价的

<?php
echo "This is a text";
?>
<?php echo "This is a test"?>

注释:

php支持'c',c++和unix shell风格的注释;例如:

<?php
echo "This is a test";//This is a one-line c++ style comment
/*This is a multi line comment
yet another line of comment*/
echo "This is yet another test";
echo "One Final Test";#This is shell-style style comment
?>

"单行"注释仅仅注释到行末或者当前的代码块,视乎哪个首先出现。

<h1>This is an <?php # echo "simple"?>example.</h1>
<p>The header above will say 'This is an example'.

小心不要嵌套'C'风格的注释,当注释大量的代码时,可能犯该错误。

<?php
/*
echo "This is a test";/*This comment will cause a problem*/
*/
?>

单行注释仅仅注释到行末或者当前的php代码块

以上就是php指令分隔符的详细内容,更多请关注二当家的素材网其它相关文章!

评论0
头像

友情提示:垃圾评论一律封号 加我微信:826096331拉你进VIP群学习群

1 2