Re: nonblocking STDIN in CLI PHP app



On May 30, 9:07 pm, yawnmoth <terra1...@xxxxxxxxx> wrote:
I think this is a better way to approach my question. Here's my
script:

<?php
$stdin = fopen('php://stdin', 'r');

stream_set_blocking($stdin, false);

$last_date = '';
while (true)
{
fread($stdin, 1024);
if ($last_date != date('g:ia'))
{
$last_date = date('g:ia');
echo "The time is now [$last_date]\r\n";
}

}

If I comment out the fread, it echo's the time once a minute. If I
leave the fread as it is, it doesn't. My question is... why?
Blocking is set to false, so why does it appear to be blocking, anyway?

Never mind... I think the following URL addresses my problem:

http://bugs.php.net/34972

.



Relevant Pages

  • Re: nonblocking STDIN in CLI PHP app
    ... If I comment out the fread, it echo's the time once a minute. ... Blocking is set to false, so why does it appear to be blocking, anyway? ...
    (comp.lang.php)
  • Re: script problem
    ... your calling syntax requires that this script either takes arguments ... This can happen because there is a script fread and a function fread ... You may use the command: ... your filename contains invalid characters. ...
    (comp.soft-sys.matlab)
  • Copy webpage, protected by session
    ... I want to copy a page from the internet with fopen and fread. ... website see php as a logged in user, and then let the same script php ... with netscape, logged in, and copy all the vars the website had stored ...
    (alt.php)
  • Copy webpage, protected by session
    ... I want to copy a page from the internet with fopen and fread. ... website see php as a logged in user, and then let the same script php ... with netscape, logged in, and copy all the vars the website had stored ...
    (comp.lang.php)
  • Re: Disabled mail function workaround?
    ... and that the php appears to have a bunch of functions ... disabled, when I run phpinfo. ... odd that you can't fread() but you can ...
    (comp.lang.php)