为什么这段代码产生"语法错误,意外'='"?

Jam*_*mes -1 php string concatenation syntax-error echo

$text . = '1 paragraph';
$text . = '2 paragraph';
$text . = '3 paragraph';
echo $text;
Run Code Online (Sandbox Code Playgroud)

此代码给出错误syntax error, unexpected '='.

问题是什么?

Jon*_*and 7

我想你想要:

$text = '1 paragraph';
$text .= '2 paragraph';
$text .= '3 paragraph';
echo $text;
Run Code Online (Sandbox Code Playgroud)

请注意,第一行不使用.=,只是使用=

  • @Happy:很乐意提供帮助 (3认同)