Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is #!/usr/bin/env required to run PHP from command line?

Often times when I see PHP that is meant to be ran from the command line, it will have this line #!/usr/bin/env php at the top of the file like this...

#!/usr/bin/env php <?php     // code ?> 

I was wanting to know if this is meant just for when the file is ran on a Linux/Unix system or is needed for running on Windows as well?

like image 794
JasonDavis Avatar asked Jan 05 '12 05:01

JasonDavis


People also ask

What are the meanings of is?

Definition of is (Entry 1 of 4) present tense third-person singular of be. dialectal present tense first-person and third-person singular of be. dialectal present tense plural of be.

What type of word is is?

Is is what is known as a state of being verb. State of being verbs do not express any specific activity or action but instead describe existence. The most common state of being verb is to be, along with its conjugations (is, am, are, was, were, being, been). As we can see, is is a conjugation of the verb be.

Is in use a word?

Definition of in use : being used All of the computers are currently in use.

What grammar is the word is?

The word “is” is always used as a verb in written and spoken English. This word is considered as a verb because it expresses existence or a state of being. It is classified under linking verbs and is a derivative of the verb “to be.” In the sample sentence: He is the most intelligent student in class.


1 Answers

The shebang line is required for auto-detection of the type of script. It enables this sort of usage:

[pfisher ~]$ chmod +x run-me.php [pfisher ~]$ run-me.php 

That line is not needed if you pass the filename as an argument to the php interpreter, like so:

[pfisher ~]$ php run-me.php 

Edit: replace "hashbang" with shebang.

like image 126
Patrick Fisher Avatar answered Sep 21 '22 11:09

Patrick Fisher