php注释代码_如何以及为什么在您PHP代码中进行注释
A comment in PHP code is a line that is not read as part of the program. Its only purpose is to be read by someone who is editing the code. So why use comments?
PH
php注释代码 A comment in PHP code is a line that is not read as part of the program. Its only purpose is to be read by someone who is editing the code. So why use comments? PHP代码中的注释是不作为程序一部分读取的行。 其唯一目的是由正在编辑代码的人员阅读。 那么为什么要使用注释呢? There are several ways to add a comment in PHP code. The first is by using // to comment out a line. This one-line comment style only comments to the end of the line or the current code block, whichever comes first. Here is an example: 有几种方法可以在PHP代码中添加注释。 第一种是使用//注释掉一行。 这种单行注释样式仅注释到该行的末尾或当前代码块,以先到者为准。 这是一个例子:
If you have a single line comment, another option is to use a # sign. Here is an example of this method: 如果您有单行注释php注释,则另一个选择是使用#号。 这是此方法的示例:
echo "hello"; 回声“你好”; #this is a comment #这是一条评论 echo " there"; 回声“那里”; ?> ?> If you have a longer, multi-line comment, the best way to comment is with /* and*/ before and after a lengthy comment. You can contain several lines of commenting inside a block. Here is an example: 如果您有较长的多行注释,最好的注释方法是在较长的注释前后加上/ *和* /。 您可以在一个块中包含多行注释。 这是一个例子:
不要混淆评论 ( Don't Mix Comments ) Although you can nest comments within comments in PHP, do so carefully. Not all of them nest equally well. PHP supports C, C++ and Unix shell-style comments. C style comments end at the first */ they encounter, so don't nest C style comments. 尽管您可以在PHP的注释中嵌套注释,但请谨慎进行。 并非所有人都嵌套得很好。 PHP支持C, C ++和Unix Shell样式的注释。 C样式注释在它们遇到的第一个* /结尾处结束,因此不要嵌套C样式注释。 If you are working with PHP and HTML, be aware that HTML comments mean nothing to the PHP parser. They won't work as intended and are likely to execute some function. So, stay away from: 如果您使用的是PHP和HTML,请注意HTML注释对PHP解析器毫无意义。 它们将无法按预期工作,并且可能会执行某些功能。 因此,请远离:
翻译自: php注释代码 (编辑:晋中站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |