Home > php教程 > php手册 > body text

PHP 错误之引号中使用变量

WBOY
Release: 2016-06-13 12:23:48
Original
874 people have browsed it

当看到错误提示
syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
这个提示,是提示变量使用的问题。
而我出现的是,语句中使用了数组,导致失败。下面看看失败的代码;
echo "我是数组,$n['x']";
?>
这样即时双引号是可以解析变量的,但是素组这样的,写法是没办法解析。修改成下面就可以了!
echo "我是数组,{$n['x']}";
?>
加上花括号{}可以让语句识别这里面是动态的。

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template