Page 1 of 1

PHP Shell Script Question

Posted: Thu Sep 28, 2006 2:38 am
by MathewByrne
Is there a simple way of determining if a person is running PHP from a CLI interpreter or viewing a php file through a browser?

Posted: Thu Sep 28, 2006 3:27 am
by Benjamin
You could probably test to see what differences there are between this output in a browser or cli.

Code: Select all

echo '<pre>';  // for browsers..
foreach ($_SERVER as $key => $value)
{
    echo "$key=$value\n";
}
echo '</pre>';