RE: [PHP] CLI question

From: Date: Thu, 18 Dec 2003 09:42:18 +0000
Subject: RE: [PHP] CLI question
Groups: php.general 
Request: Send a blank email to php-general+get-172929@lists.php.net to get a copy of this message
On 17 December 2003 21:33, Jay Blanchard wrote: > [snip] > I'm using the CLI version 4.3.4 on Windows XP Pro. The script I'm > writing has only a couple of functions, a couple of "if" conditionals > and a "while" loop. At the very top of the script I have an echo > statement with a message I want printed to the console window. The > problem is that it's not echoed until all of the functions and other > stuff is executed. Why is this the case? Anything I can do to get the > echo statement to run first thing? > [/snip] > > Use output buffering and flush the echo statement .... > http://us2.php.net/manual/en/function.flush.php Shouldn't that be *don't* use output buffering and...? The flush() function has nothing to do with output buffering, and if output buffering is on you will need ob_flush() as well. Another (and probably better) solution is to create a php-cli.ini file, which will be picked up only by your CLI version, and put output_buffering = Off implicit_flush = On in it. (Implicit flushing is usually expensive and inappropriate when generating Web pages, but usually exactly what you want when running from the command line.) Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@leedsmet.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#172929) next »