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

前端 未结 11 655
你的背包
你的背包 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:35

    From https://php.net/manual/en/migration53.deprecated.php

    "Deprecated features in PHP 5.3.x ...Comments starting with '#' are now deprecated in .INI files."

    There you have it. Hash '#' appears to remain as a comment option by default by not being deprecated. I plan to use it to distinguish various layers of nested if/else statements and mark their closing brackets, or use to distinguish code comments from commented out code as others have suggested in related posts. (Note: Link was valid/working as of 4/23/19, although who knows if it'll still be working when you're reading this.)

提交回复
热议问题