On Sat, 2003-09-20 at 00:59, Dan Anderson wrote:
> Why are you using php:// below?  If stdin is a file './stdin' will

Because it is the correct way to retrieve input from standard input.

    http://www.php.net/wrappers.php

> suffice (or the path instead of ./).  If you want to run the PHP script
> in stdin you should use one of the following:
> include()
> include_once()
> require()
> require_once()
> See the manual at php.net for pertinent sections...

I don't want to run a script from stdin, I want to retrieve user input
from the keyboard. What the heck are you smoking?

> >     if( ($stdin = fopen( 'php://stdin', 'r' )) === false )
> >     {                                                     
> >         echo 'Failed to open STDIN'."\n";
> >         exit();
> >     }          
> 
> I seem to remember stream_set_blocking being either experimental or deprecated.
> If I remember correctly its for use with the function fsock_open().
> >     stream_set_blocking( $stdin, false );

No stream_set_blocking() is the correct function. The others are
deprecated because they are less generic for streams:

    This function was previously called as set_socket_blocking()
    and later socket_set_blocking() but this usage is deprecated.

> >     $count = 0;                          
> WTF are you thinking?  You really need to read the documentation. 
> Instead of this:

You sir, are a moron, you are calling me a moron and yet you are the one
who doesn't know what you are talking about.

> >     while( 1 ) 
> >     {         
> > echo 'Foo: '.($count++)."\n";
> >         if( ($char = fread( $stdin, 1 )) !== false )
> >         {
> >             echo $char."\n";
> >         }
> >         else
> >         {
> >             echo 'Fooo!'."\n";
> >         }
> >     }    
> 
> Try:
> 
> <?php
> 
> $stdin = fopen("./stdin","r");
> while ($stdin AND (!(feof($stdin))))
> { echo fread($stdin,4096); }
> 
> ?>
> 
> Much simpler, correct?

This is not what I want, I want individual keystrokes as they come in
form the keyboard. I'm quite sure I know what I'm doing.

> BTW: The infinite loop you have above could be the reason your script is
> acting erratically.  PHP kills off scripts after they run for so long --
> you may just be catching it in different versions of the loop.

Infinite loop, shmoop, the script ran for less than a second. Long
enough for $count to get as high as 2000 tops. I've run many, MANY
scripts as CGI shell script, and never has it bailed from an infinite
loop successfully in less than a second.

> Also BTW: I understand what you mean when you say CGI but not CLI
> version of PHP, but I really don't think the term CGI applies in this
> case.  CGI means Common Gateway Interface -- or a way to execute
> programs in a special directory designed to keep them from r00ting the
> system.  In PHP things such as headers are automatic -- no need to type:

I use the term CGI for the mode in which PHP was compiled, NOT, AND I
REPEAT NOT, because I'm using it as a Common Gateway interface.

> print "Content-type: text/html\n\n";
> 
> It's a server side scripting language designed to be embedded in things
> like web pages and be able to be run without much security concerns. 
> (i.e. not running a CGI perl scrip as /usr/bin/perl (i.e. not in tainted
> mode) -- ouch!  and these are the silly things users sometimes do)

Thanks for the lesson, I'll be sure to pretend I didn't know what CGI
is. BTW, if I were a newbie at PHP, your message would make me never
want to make another post. Even in the event you are correct, such a
pathetic response is no way to treat those of lesser knowledge. Now go
read the docs, and learn some more before trying to tell me what's what.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to