CLI - php shell script worked under php4, breaks under php5
| From: | weston at leary2 dot csoft dot net | Date: | Mon, 26 Jun 2006 02:10:58 +0000 |
| Subject: | CLI - php shell script worked under php4, breaks under php5 | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-238601@lists.php.net to get a copy of this message | ||
A while back I wrote a little read-eval-print loop that essentially constituted a very basic php
shell:
http://weston.canncentral.org/misc/phpsh.txt
This has almost always run fine for me with the cgi versions of php 4, and often proves to be a
great help in quickly testing various snippets of code.
However, I just recently tried to use this with PHP 5.1.2, and found that it doesn't work.
Specifically, it seems to wait for input to be typed without issuing a prompt. Upon entering a line,
there's no response, until one presses ctrl-d. At this point, it throws a parse error:
syntax error, unexpected ')' in phpsh5(23): eval()'d code on line 1
regardless of whether or not there are in fact any unmatched parenths (or any parenths at all) on
the entered line. And it apparently doesn't execute any of the code at all until one enters
"exit" as a command.
I've tried switching from /dev/stdin to php://stdin, tried adding -f or -a to the processing
options.... nothing seems to make a difference. I also tried removing my "_readln()"
function, and simple entering a default expression. This produces the expected (if repetetive and
ultimately practically useless) results, so I assume it's something in my _readln() function
that throws it off.
Any ideas how to get this to work with PHP 5?