Home >Backend Development >PHP Tutorial > 用双引号赋值的字符串中,是不能包含数组变量吗?该怎么解决

用双引号赋值的字符串中,是不能包含数组变量吗?该怎么解决

WBOY
WBOYOriginal
2016-06-13 13:27:50911browse

用双引号赋值的字符串中,是不能包含数组变量吗???
我有个语句是这么写的:

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
$str = "( $value['title'], $value['artiste'], $value['album'], $value['by'], $value['lrc'], $timeStamp, $timeStamp), ";



报错:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

请问像这种在双引号里使用数组变量的,必须要拆开写吗?不能这么包含?

谢谢!

------解决方案--------------------
do it like this

PHP code

$str = "( {$value['title']}, {$value['artiste']}, {$value['album']}, {$value['by']}, {$value['lrc']}, $timeStamp, $timeStamp), "; <div class="clear">
                 
              
              
        
            </div>
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