News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Johan Mares' Blog:
Running PHP CLI shell scripts
January 06, 2009 @ 08:47:57

Johan Mares has a recent post about using PHP on the command line:

I already knew how to run PHP scripts from the command line (CLI), although I never really used it. What was new to me was that there are 2 ways of doing this. The first one is by using the php command and the second, and new for me, is by adding a shebang on the first line of your script.

His first way is to run the PHP file through the interpreter directly (via a command line call to something like "php myfile.php"). The second it to actually include the path to the interpreter inside the PHP file itself and use the shell to execute the contents based on that (adding something like "#!/path/to/php" at the top). Then you just make the file executable and you can run it like any other binary file.

0 comments voice your opinion now!
cli commandline script method interpreter shebang


blog comments powered by Disqus

Similar Posts

Sean Coates' Blog: Use `env`

Wez Furlong's Blog: Background/batch/workflow processing with PDO::PGSQL

Sebastian Göttschkes' Blog: Extending the Testclass for Unittests

Slawek Lukasiewicz's Blog: Zend Framework: Reflection

Community Crosstalk: Matthew O'Phinney & Scott Johnson on Dynamic Function/Method Calls


Community Events





Don't see your event here?
Let us know!


laravel language code release symfony application introduction library configure community podcast developer install threedevsandamaybe list api interview bugfix wordpress series

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework