Re: command line or http browser?
| From: | Curt Zirzow | Date: | Thu, 24 Jul 2003 16:22:44 +0000 |
| Subject: | Re: command line or http browser? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-156679@lists.php.net to get a copy of this message | ||
* Thus wrote ermelir (ermelir@ifrance.com):
> Hi list,
>
> I search to detect if a script is call from command line or if the call from
> a client http browser.
> for doing that, I test if:
> php_sapi_name()=='cli'
> which returns TRUE if script calls from command line; this work fine with
> PHP 4.2, but with PHP 5 php_sapi_name() returns cgi-fcgi
> so, I would know if with others php version there is others returns values?
> and if there is another way to detect if script is call from command line?
> thanks in advance for yours answers
This is a good point. I'm not aware of any other names, although I
have to admit i wan't aware of the sapi_name function either.. :)
There aught to be a better method of detecting whether you are in
cli mode or module mode. If this is the only way to determain it I
would make a suggestion to the php developers to have a way to
detect what mode your in. Detecting by a string value is very poor
method of doing it.
Ok, now after reading the docs, I see why its a string.... Some one
came up with a list of names, I have no clue where he got it his
reference tells me nothing.
- aolserver
- activescript
- apache
- cgi-fcgi
- cgi
- isapi
- nsapi
- phttpd
- roxen
- java_servlet
- thttpd
- pi3web
- apache2filter
- caudium
- apache2handler
- tux
- webjames
- cli
- embed
- milter
Curt
--
"I used to think I was indecisive, but now I'm not so sure."