You are here: Re: [PHP] Need best way to determine if cronjob or external browser called my script « PHP « IT news, forums, messages
Re: [PHP] Need best way to determine if cronjob or external browser called my script

Posted by Bret Hughes on 01/19/05 19:08

On Wed, 2005-01-19 at 07:47, Al wrote:
> I'm working on a script that can be initiated by a cronjob or from a browser.
>
> I want the script to act differently depending on which one called it.
>
> --

I do not know what the definitive answer is but there are a bunch of
environment differences. Here is one taken from

http://us2.php.net/features.commandline

[bhughes@sonecdm elevatetest]$ cat testbrowser.php
<?php
if ($_SERVER['SERVER_PORT']) { echo "SERVER MODE\n"; }
else { echo "CLI MODE\n"; }
?>


results from wget:

[bhughes@sonecdm elevatetest]$ wget -q --output-document=-
https://localhost/elevatetest/testbrowser.php
SERVER MODE
[bhughes@sonecdm elevatetest]$

results from cli

[bhughes@sonecdm elevatetest]$ php testbrowser.php
Content-type: text/html
X-Powered-By: PHP/4.3.6

CLI MODE
[bhughes@sonecdm elevatetest]$

mozilla returns

SERVER MODE

HTH

Bret

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация