Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Shebang problems with some PHP environments

12:22 pm on Aug 27, 2013 (gmt 0)

Full Member

5+ Year Member Top Contributors Of The Month

joined:Sept 30, 2009
votes: 1

I am working on collaboratively developed code run on lots of different websites and script environments.

Inline comments throughout these scripts provide guidance to the various developers, and creating in house rules to consistently write these comments was proposed.

Under consideration:
# New line hashtag comments are an introduction for following code
#! New line shebangs comments highlight issues with or ways the script could be improved
While PHP supports inline comments that start with a hashtag and ignore everything thereafter on the same line, I'm concerned that hashtags immediately followed by the exclamation mark (shebangs) might be an exception to this as some older scripts seem to specify PHP scripting paths proceed by shebangs.

As the code is run in different environments it is difficult to know if these types of comments might provide unforeseen errors and I was hoping somebody might be more familiar with PHP and shebangs.
4:42 pm on Aug 27, 2013 (gmt 0)


WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
posts: 15756
votes: 0

why not use slashes for inline and block?



and maybe TODO: which is supported by most editors to show possible improvements

hash commenting seems archaic and, as you say, open to interpretation
11:09 pm on Aug 27, 2013 (gmt 0)

Senior Member

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 7, 2003
votes: 0

#! as the first line in a script on a unix (or unix-like) machine should indeed point to the command processor for the script itself.
Shell scripts use this to specify the shell of choice (e.g. #!/bin/sh )
It's rather uncommon to use it for php, but the shell will execute any executable text file with the specified command processor if it can.

I'd avoid the notation if you hope it's a comment n the mind of the reader.

As jatar_k said: use // ... and /* ... */ everybody will get it.