我有以下错误:
解析错误:语法错误、意外T_STRING、期望在 .. 中出现","或";"。/public_html/wp-content/themes/nano/include/galleri.php 在第 64 行**
请帮助我完成代码工作!
http://pastebin.com/B0ndywWc
有问题的代码:
<?php
$ccfit_img_thumb = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_id() ), 'ccfit_thumb', false );
$ccfit_img_big = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_id() ), 'ccfit_big', false );
echo '
<div class="col-md-4">
<div class="inner">
<a href="'. $ccfit_img_big[0] .'"></a>
<img src="'. $ccfit_img_thumb[0] .'">
<h2>'. get_the_title() .'</h2>
<p>'. get_the_content() .'</p>
<hr>
<?php
if (isset($featuredImages) && is_array($featuredImages)) {
foreach($featuredImages as $images) {
$thumb = $images['thumb']; // <---- line 64
$fullImage = $images['full'];
print ' <a class="fancybox" href="'. $fullImage .'" style="text-align:center">« Take a look »</a> ';
}
}
?>
</div></div>';
?>
错误实际上在第 53 行:
echo '
你永远不会关闭那句话...或者至少,您正在尝试将 PHP 标签嵌套在 echo 语句中。
在第 64 行实际发生的是,'thumb'
中的第一个引号被解释为 echo 的结束引号 - 导致thumb
成为意外的字符串。
内部 <?php
标记不会被解释 - 它只是被视为被回显的字符串的一部分。
注意我在上面的问题中编辑的代码中的语法突出显示,可能会更清楚发生了什么。
$thumb = $images['thumb'], <------------------- line 64
$fullImage = $images['full'],
应该是
$thumb = $images['thumb'];
$fullImage = $images['full'];