21xrx.com
2024-04-19 01:28:03 Friday
登录
文章检索 我的文章 写文章
PHP 注释
2021-07-21 18:55:35 深夜i     --     --
P H P


PHP 中的注释

PHP 代码中的注释是不作为代码的一部分执行的一行 程序。 它的唯一目的是让正在查看代码的人阅读。

注释可用于:

  • 让别人理解你的代码
  • 提醒自己你做了什么——大多数程序员在一两年后回到自己的工作中,不得不重新弄清楚他们做了什么。 注释可以提醒您编写代码时的想法

PHP 支持多种注释方式:

单行注释的语法:

<!DOCTYPE html>
<html>
<body>

<?php
// This is a single-line comment

# This is also a single-line comment
?>

</body>
</html>

多行注释的语法:

<!DOCTYPE html>
<html>
<body>

<?php
/*
This is a multiple-lines comment block
that spans over multiple
lines
*/
?>

</body>
</html>

使用注释省略部分代码:

<!DOCTYPE html>
<html>
<body>

<?php
// You can also use comments to leave out parts of a code line
$x = 5 /* + 15 */ + 5;
echo $x;
?>

</body>
</html>

 

 

  
  
下一篇: PHP 变量

评论区

{{item['qq_nickname']}}
()
回复
回复