PHP Shell Script Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
MathewByrne
Forum Commoner
Posts: 38
Joined: Sat Mar 27, 2004 9:49 pm
Location: Australia

PHP Shell Script Question

Post 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?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post 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>';
Post Reply