hp 支持 c,c++ 和 unix shell 风格(perl 风格)的注释。例如:
<?php
echo "This is a test" ; // This is a one-line c++ style comment
echo "This is yet another test" ;
echo 'One Final Test' ; # This is a one-line shell-style comment
?>单行注释仅仅注释到行末或者当前的 PHP 代码块,视乎哪个首先出现。这意味着在 // ... ?youjiankuohaophpcn 或者 # ... ?> 之后的 HTML 代码将被显示出来:?> 跳出了 PHP 模式并返回了 HTML 模式,// 或 # 并不能影响到这一点。如果启用了 asp_tags 配置选项,其行为和 // %> 或 # %> 相同。不过,</script> 标记在单行注释中不会跳出 PHP 模式。
<h1>This is an <?php # echo 'simple'; ?> example</h1> <p>The header above will say 'This is an example'.</p>
C 风格的注释在碰到第一个 */ 时结束。要确保不要嵌套 C 风格的注释。试图注释掉一大块代码时很容易出现该错误。
<?php */ ?>
PHP注释有两种:
用双斜杠 // 这种是注释掉一行代码比如
立即学习“PHP免费学习笔记(深入)”;
//$message = 'abc';
用 /* 和 */ 这种是注释掉一大段的,比如
/* $today = 'tomorrow'; */
以上就是PHP注释掉代码有几种写法?分别是什么?的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号