I have a script which is running on Apache and also can be executed from command line.
How can i know, on what is php script running, apache or command line?
I have a script which is running on Apache and also can be executed from command line.
How can i know, on what is php script running, apache or command line?
There is a constant build in PHP that you can use PHP_SAPI
. If you are on the commandline the value of this constant is cli
than you are on the command line. Every other value like cgi
, cgi-fcgi
, etc.
Why not add a parameter and only pass it when invoking from the command line?
Create a page upload it and browse to it.
See page contents below.
<?php phpinfo(); ?>