Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'General Discussion' started by mmatos, Dec 12, 2006.

  1. mmatos

    mmatos Member

    Dec 9, 2006
    Likes Received:
    Trophy Points:
    I have a script that I wrote that does some maintenance. I called it regularly using a cron job to fetch the url: (fetch

    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!
  2. Spiral

    Spiral BANNED

    Jun 24, 2005
    Likes Received:
    Trophy Points:
    Hint: Apache server variables are only passed to the script when run from the web

Share This Page