Difference between # and // in php?

<?php # some comment ?> 

and

 <?php // some comment ?> 

are used for one-line commenting of code in PHP, and the first - from shell scripts, and // - from C ++.

However, I am curious to find out if there are any differences between using // and # for one-line commenting, and each has come across specific cases where one or the other should not be used.

The only difference I could think of is one character in '#' and two in '//', so maybe larger scripts will have a small size and / or performance?

+4
source share
1 answer

It’s easier for me to type // double-pressing a key on my keyboard that moves only my right little finger with one press and double-click.

If I want to do # , I need to use both hands, and the movements are β€œbigger”;). The same goes for echo and print .

But in the "print" and "echo" scripts, you can hear the argument that one function is a bit slower, however I'm not sure which one right now;), but this is really what is not a deal break when optimizing the code I think.

According to this test, echo runs a little faster: Should I use echo or print in php scripts?

+3
source

Source: https://habr.com/ru/post/1485837/


All Articles