Differentiate from CLI & browser
Posted: Sat Mar 08, 2008 2:18 am
Hi
Whenever I want to differentiate from a script running in command-line mode from the browser, I do this
Its worked all this time. But theres one server powered by DirectAdmin, that shows different data
1. UNIQUE_ID which I've never come across till date
2. Dont argc & argv get set only when run in CLI ?
Is the configuration custom-set ?
Linux | Apache 2.2.6 | PHP 5.2.5
Whenever I want to differentiate from a script running in command-line mode from the browser, I do this
Code: Select all
if (isset($_SERVER['argc'])) # Script being run in Command line mode
{
//
}
else
{
//
}
if ($_SERVER['HTTP_HOST'] == "localhost") # my PC
{
//
}
else # Server
{
//
}Code: Select all
Array
(
[UNIQUE_ID] => S0ZwZtBzJT4AACXaB2UABAAP
[HTTP_HOST] => mydomain.com
[SERVER_NAME] => mydomain.com
[argv] => Array
(
)
[argc] => 0
)2. Dont argc & argv get set only when run in CLI ?
Is the configuration custom-set ?
Linux | Apache 2.2.6 | PHP 5.2.5