Skip to content
Advertisement

PHP comments: # vs. //

Lately I’ve been using # instead of // for doing single line comments inside my code. However, I see most of the people prefer //.

Is there a particular reason for preferring them instead of #? Performance? File weight? Anything?

Advertisement

Answer

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 😉

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement