PHP can run under CLI (Command Line Interface) as well as via HTTP. If you want to restrict a script to CLI-only use this simple check:
if (php_sapi_name() != 'cli') {
exit('ERROR: Not in CLI mode' . PHP_EOL);
}

PHP can run under CLI (Command Line Interface) as well as via HTTP. If you want to restrict a script to CLI-only use this simple check:
if (php_sapi_name() != 'cli') {
exit('ERROR: Not in CLI mode' . PHP_EOL);
}