我正在编写一个代码,使用分配给图像的标签来过滤一堆库图像。然而,我遇到了这个解析错误
分析错误:语法错误,意外的"}",应为"、"或";"
我很困惑,因为我看到它所指的"}"被正确地打开和关闭了。如有任何帮助,我们将不胜感激。这是抛出错误的线路
<button class="cbp-filter-item"><?php if($key == 0){echo 'cbp-filter-item-active'};?> data-filter=".<?php echo strtolower(str_replace(" ","-",$tag)); ?>"><?php echo ucfirst($tag); ?></button> ","-",$tag)); ?>"><?php echo ucfirst($tag); ?></button>
这是代码片段>
<?php if(isset($tagsFilter) && count($tagsFilter)):
foreach($tagsFilter as $key=>$tag):
?>
<button class="cbp-filter-item"><?php if($key == 0){echo 'cbp-filter-item-active'};?> data-filter=".<?php echo strtolower(str_replace(" ","-",$tag)); ?>"><?php echo ucfirst($tag); ?></button>
<?php endforeach; endif;?>
</div>
<?php endif;?>
如有任何帮助,我们将不胜感激。
谢谢,赛。
更改此行:
<?php if($key == 0){echo 'cbp-filter-item-active'};?>
有了这个:
<?php if($key == 0){echo 'cbp-filter-item-active';} ?>