最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

how to solve PHP Parse error: syntax error, unexpected token "echo" in php shell code on line 2 in interactive

programmeradmin0浏览0评论

I opened an interactive PHP shell using php -a and started entering the statements

php > "12" == 12
php > echo "12" == 12
php > echo ("12" == 12)
php > echo ("12" == 12);

And then I got the error

PHP Parse error:  syntax error, unexpected token "echo" in php shell code on line 2

I was expecting to get true or false, why doesn't the interactive shell tell me what the value of "12" = 12 is?

I opened an interactive PHP shell using php -a and started entering the statements

php > "12" == 12
php > echo "12" == 12
php > echo ("12" == 12)
php > echo ("12" == 12);

And then I got the error

PHP Parse error:  syntax error, unexpected token "echo" in php shell code on line 2

I was expecting to get true or false, why doesn't the interactive shell tell me what the value of "12" = 12 is?

Share Improve this question asked Feb 3 at 12:59 camilajennycamilajenny 5,0646 gold badges33 silver badges67 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

The error was because I didn't finish the instructions, so the interactive shell interpreted my statements as one long instruction

"12" == 12 echo "12" == 12 echo ("12" == 12) echo ("12" == 12);

which has a syntax error on the first echo.

The solution is to end the instruction with a semicolon

 echo "12" == 12 ? 'true' : 'false';

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论