Connecting Tech Pros Worldwide Help | Site Map

auto detect CLI

steve
Guest
 
Posts: n/a
#1: Jul 17 '05
How can I detect in php that I am running from CLI (command line), and
not the browser. I hate to put a constant in each script:
e.g. define(’CLI’, 1)...

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-auto-det...ict169501.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=568027
Pedro Graca
Guest
 
Posts: n/a
#2: Jul 17 '05

re: auto detect CLI


["Followup-To:" header set to comp.lang.php.]
steve wrote:[color=blue]
> How can I detect in php that I am running from CLI (command line), and
> not the browser. I hate to put a constant in each script:
> e.g. define(’CLI’, 1)...[/color]

http://www.php.net/manual/en/function.php-sapi-name.php

and, since you're already reading the manual,
also read about command line features:
http://www.php.net/manual/en/features.commandline.php
--
USENET would be a better place if everybody read: | to mail me: simply |
http://www.catb.org/~esr/faqs/smart-questions.html | "reply" to this post, |
http://www.netmeister.org/news/learn2quote2.html | *NO* MIME, plain text |
http://www.expita.com/nomime.html | and *NO* attachments. |
Closed Thread


Similar PHP bytes