richardoneill.com.au » Articles » PHP Command Line Tip

PHP Command Line Tip

11 September 2007 PHP, Programming

Here's a quick tip for working with the command line in PHP.

If you've ever run a PHP script via the command line, you would have noticed that output from the script is not printed until the script has finished.

If you need your output displayed in real time, you can open a stream to the command line...

$stdout = fopen('php://stdout', 'w');

Simply write any output to the stream and it will be printed on the command line in real time...

fwrite($stdout, "Hello CLIn");

Comment on this article
Name
Website
Canberra Web Design