Should be easy: Determine is script is running as shell or web?

mmatos

Member
Dec 9, 2006
9
0
151
I have a script that I wrote that does some maintenance. I called it regularly using a cron job to fetch the url: (fetch http://www.myserver.com/script.php).

I'm making some changes and am now doing it like this:

/usr/local/bin/php /path/to/my/script.php

Now, the script will usually be called this way, BUT on occasion I will need to call it by hand.

I'd like to change the line feeds from \n to <br> depending on whether it's run locall or through a page request.

I can't seem to find any documentation on determining what environment PHP is running in. I'm sure it's something easy like "IsShell()" or something...

Help? Thanks!
 

Spiral

BANNED
Jun 24, 2005
2,018
8
193
Hint: Apache server variables are only passed to the script when run from the web