Re: [PHP] stdout as input

2009-09-24 Thread bdunlap
> echo bob | myScript.php
>
> In myScript.php, I'm doing:
>
>  $handle = popen( 'php://stdin', 'r' );
>  echo var_export( $handle, TRUE ) . "\n\n";

What output are you getting from those lines, and what were you
expecting? $handle is just a resource, same as if you opened a regular
file -- you still need to read data from it with something like
fgets().

If I'm writing a quick-and-dirty script to process piped-in data, I
find this construct to work reasonably well:

while(!feof(STDIN)) {
$line = fgets(STDIN);

// trim() $line here if I don't want trailing/vertical whitespace

// now do something with $line
}

The one weakness of that form is that I always get an empty line at
the end, but as long as I check for that in the loop (which I should
usually be doing anyway), it's no problem.

Ben

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



Re: [PHP] Re: session.gc_maxlifetime

2009-09-24 Thread bdunlap
> it could be ip address changes. interesting thought.

As far as I'm aware, PHP session-management doesn't care about source
IP, out-of-the-box -- your app would have to be coded to care. Plus I
suspect you would have started seeing the problem a long time ago, if
changing source IPs were the cause.

Ben

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