Reputation: 1626
I'm learning to use the PHP interactive shell, but I'm having trouble with multi-line code.
Using backslashes like in the UNIX shells doesn't seem to work. What am I doing wrong ?
php > function test(){\
php { echo "test";\
php { }\
php > test();
PHP Parse error: syntax error, unexpected T_ECHO, expecting T_STRING in php shell code on line 2
Upvotes: 2
Views: 3109
Reputation: 284816
Just don't escape it:
php > function test()
php > {
php { echo "test";
php { }
php > test();
test
However, you will have problems in certain cases, such as:
php > if(conditional)
php > {
php { // ...
php { }
php > else
php > {
php { // ...
php { }
It thinks the if is over before it sees the else, so you get a "unexpected T_ELSE". In this case, there's a work-around:
php > if(conditional)
php > {
php { // ...
php { } else
php > {
php { // ...
php { }
Upvotes: 2