Within a php file, how can you tell if it's being called by the
webserver, or by the cli?
I have some pages that I developed to be served, but now we want to
run some of them as cron jobs. I have to change some of the path
references ( our cron job scripts reference include files in the
webserver directory, and relative paths in the include files break
when they are called by a script in another directory ), and to make
everything more interoperable, I need to reference things based on
whether it's being called by Apache or by the cli. Specifically, I'm
making a reference to $_SERVER['DOCUMENT_ROOT'], which is empty when
called by the cli.
So, I need to know if the script is being called by apache or the
command line, so I can choose how to references certain included
files. How should I do this?
webserver, or by the cli?
I have some pages that I developed to be served, but now we want to
run some of them as cron jobs. I have to change some of the path
references ( our cron job scripts reference include files in the
webserver directory, and relative paths in the include files break
when they are called by a script in another directory ), and to make
everything more interoperable, I need to reference things based on
whether it's being called by Apache or by the cli. Specifically, I'm
making a reference to $_SERVER['DOCUMENT_ROOT'], which is empty when
called by the cli.
So, I need to know if the script is being called by apache or the
command line, so I can choose how to references certain included
files. How should I do this?
Comment