Home > Backend Development > PHP Tutorial > PHP error using variables in quotes_PHP Tutorial

PHP error using variables in quotes_PHP Tutorial

WBOY
Release: 2016-07-21 15:46:22
Original
936 people have browsed it

When you see the error message
syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
, this prompt indicates a problem with variable usage.
What happened to me was that an array was used in the statement, causing it to fail. Let’s look at the failed code below;
echo "I am an array, $n['x']";
?>
In this way, the instant double quotes can parse the variables , but the writing method of element group cannot be parsed. Just modify it to the following!
echo "I am an array, {$n['x']}";
?>
Adding curly braces {} allows the statement to identify that it is dynamic of.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320146.htmlTechArticleWhen you see the error message syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING, this prompt is to prompt the use of variables. problem. And I show up...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template