It's available to browser,
but I don't want it to execute when browsed by user,
say,when browsed should exit,
is there a way to detect whether it's currently Cmmand Line Mode?
It's available to browser,
but I don't want it to execute when browsed by user,
say,when browsed should exit,
is there a way to detect whether it's currently Cmmand Line Mode?
See:
Short story: php_sapi_name()
.
Here is a trick:
You can check for the $argc/$argv parameters which are always available in CLI mode.
#!/usr/bin/php
<?php
ini_set('register_argc_argv', 0);
if (!isset($argc) || is_null($argc))
{
echo 'Not CLI mode';
} else {
echo 'CLI mode';
}
Another trick, $_SERVER
has variables that are only set in CLI mode.