Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13087 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98931 invoked by uid 1010); 30 Sep 2004 21:52:03 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 98819 invoked from network); 30 Sep 2004 21:52:01 -0000 Received: from unknown (HELO iko.gotobg.net) (80.168.8.116) by pb1.pair.com with SMTP; 30 Sep 2004 21:52:01 -0000 Received: from pd95e96a5.dip.t-dialin.net ([217.94.150.165] helo=[192.168.0.36]) by iko.gotobg.net with asmtp (Exim 4.41) id 1CD8qL-0000iD-Hi; Fri, 01 Oct 2004 00:52:05 +0300 Message-ID: <415C7FA1.1030606@hristov.com> Date: Thu, 30 Sep 2004 23:50:25 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8a4) Gecko/20040918 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jason Garber CC: internals@lists.php.net References: <606653278.20040930171001@ionzoft.com> In-Reply-To: <606653278.20040930171001@ionzoft.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - iko.gotobg.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - hristov.com X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PHP-DEV] CLI Constant From: php@hristov.com (Andrey Hristov) Jason Garber wrote: > Hello internals, > > What is the best way, from within a php script, to tell that the > script is being run on the command line? > > I've used if(defined('STDIN')) but that seems kind of kludgey. > > If there is no better way, perhaps we could add constant called > (SAPI_TYPE = 'CLI') or something like that to the language to > facilitate this? > I think this is a good idea. A hackish way is also if (in_array($_SERVER['argv'][0], array($_SERVER['PHP_SELF'],'-'), 1)) //the second one is for php -r Andrey