Can I use a hash sign (#) for commenting in PHP?

前端 未结 11 706
你的背包
你的背包 2021-01-31 13:07

I have never, ever, seen a PHP file using hashes (#) for commenting. But today I realized that I actually can! I\'m assuming there\'s a reason why everybody uses

11条回答
  •  你的背包
    2021-01-31 13:26

    2021 UPDATE: As of PHP 8, the two characters are not the same. The sequence #[ is used for Attributes.(Thanks to i336 for the comment)

    Original Answer:

    The answer to the question Is there any difference between using "#" and "//" for single-line comments in PHP? is no.

    There is no difference. By looking at the parsing part of PHP source code, both "#" and "//" are handled by the same code and therefore have the exact same behavior.

提交回复
热议问题