Home  >  Article  >  Backend Development  >  unexpected 'echo' (T_ECHO) in php shell code

unexpected 'echo' (T_ECHO) in php shell code

WBOY
WBOYOriginal
2016-08-18 09:16:364046browse

php -a
Interactive mode enabled
php > 2+5
php > echo 2+5;
PHP Parse error: syntax error, unexpected 'echo' (T_ECHO) in php shell code on line 2
php > echo 2+5;
7

Please explain this weird result.
Two echo 2+5; have different results

Reply content:

php -a
Interactive mode enabled
php > 2+5
php > echo 2+5;
PHP Parse error: syntax error, unexpected 'echo' (T_ECHO) in php shell code on line 2
php > echo 2+5;
7

Please explain this weird result.
Two echo 2+5; have different results

Because you are missing a semicolon the first time, it thinks your statement has not ended.
is equivalent to

<code>2+5 echo 2+5;</code>

This is usually a grammatical error. As the brother above said, a semicolon is missing;

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn