PHP Comments # vs //
Lately I've been using #
instead of //
for doing single line comments inside my Code. However, I see must of the people prefer //
.
Is there a particular reason for preferring them instead of #
? Performance? File weight? Anything?
It doesn't change a single thing, I'd say ; it's just a matter of habits :
//
comes from C , and exists in several languages used by lots of people. #
comes from shell and Perl, and exists in not as many "important" languages as //
-- so less people use it. And why are those two both available in PHP ? Well, PHP has been built with people knowing both C, Shell, and Perl, and they have brought what they liked from those languages ;-)
I'd probably stick with //
simply because it's the same in javascript, and when you code php, you're likely going to have some javascript in your files as well. (Most websites use js nowadays)
This way your comments look the same, regardless of the language, and it'd ease readability a small bit.
I would only suggest you use // or /* */. As your programs grow you may wish to use a documentator like phpdoc to automate documentation for your program and most of these documentators as well as IDE's will only accept these two.
链接地址: http://www.djcxy.com/p/10190.html上一篇: PHP成员变量的大括号语法
下一篇: PHP评论#vs //