Heim  >  Artikel  >  Backend-Entwicklung  >  unexpected 'echo' (T_ECHO) in php shell code

unexpected 'echo' (T_ECHO) in php shell code

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

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

请解释一下这个怪异的结果。
两次echo 2+5;有不同的结果

回复内容:

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

请解释一下这个怪异的结果。
两次echo 2+5;有不同的结果

因为你第一次少了个分号,它认为你的语句未结束。
相当于

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

这种一般都是语法错误,如楼上兄弟所说漏了分号了;

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn