当我试图将一个小表保存到数组中时,我得到错误
Parse error: syntax error, unexpected $end in
。我认为这是因为表中的"answers",我尝试使用<<
array(
'content_id' => '',
'content_type_id' => '8',
'content_uri' => 'technical-information',
'content_name' => 'Technical Information',
'content_title' => '',
'content_heading1' => '',
'content_heading2' => '',
'content_heading3' => '',
'content_heading4' => '',
'content_body' => '<h2>Internal Dimensions</h2>
<table class="dimensions">
<thead>
<tr><th>Garage Area</th>
<th>Ft.ins</th><th>mm</th></tr>
</thead>
<tbody>
<tr>
<td>Length</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Width</td>
<td>6'11"</td>
<td>2100mm</td>
</tr>
<tr>
<td>Height</td>
<td>7'3"</td>
<td>2200mm</td>
</tr>
</tbody>
</table>',
'content_body_short' => '',
我个人更喜欢这种语法,如果我有很多引号嵌入…
$variable = <<<XYZ
<html>
<body>
'Some' quotes "HERE"!
</body>
</html>
XYZ;
echo $variable;
"XYZ"是您选择的任意字符串。PHP将假定所有内容都是针对$variable
的,直到它在一行中单独找到XYZ;
。查看更多信息
如果要在由该字符分隔的字符串中使用该字符,请使用'
转义。