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

Hubro picture Hubro · Feb 1, 2012 · Viewed 26.6k times · Source

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 // instead though, so here I am.

Is there any reason, aside from personal preference, to use // rather than # for comments?

Answer

Aziz picture Aziz · Feb 1, 2012

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.