[EMAIL PROTECTED] wrote:
> 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?
>
Works for me, PHP 5.1.4. Prehaps you have some kind of output buffering
enabled. Using the -n command line switch will disable your php.ini
which should stop anything like that.
The syntax error you are getting is caused by not entering any input.
Your line 23 becomes:
$returnval = eval("return();");
Return expects some value to be provided, hence the syntax error.
David
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php