我在这行代码中遇到语法错误,并且不知道它的正确格式。
这是我遇到问题的部分 -
echo "
<ul>";
foreach($photos as $photo) {
$farm = $photo['farm'];
$server = $photo['server'];
$photo_id = $photo['id'];
$secret = $photo['secret'];
$photo_title = $photo['title'];
<li><img src="http://farm'.$photo['farm'].'.static.flickr.com/'.$photo['server'].'/'.$photo['id'].'_'.$photo['secret'].'_t.jpg" alt="'.$photo['title'].'" ></li>
问题在于li标签。我该如何正确格式化?
答案 0 :(得分:2)
根据评论,您可能意味着在最后一行中使用以下内容:
echo '<li><img src="http://farm'.$photo['farm'].'.static.flickr.com/'.$photo['server'].'/'.$photo['id'].'_'.$photo['secret'].'_t.jpg" alt="'.$photo['title'].'" ></li>';
答案 1 :(得分:2)
应引用<li>
部分。尝试:
echo "
<ul>";
foreach($photos as $photo) {
$farm = $photo['farm'];
$server = $photo['server'];
$photo_id = $photo['id'];
$secret = $photo['secret'];
$photo_title = $photo['title'];
echo '<li><img src="http://farm' . $photo['farm'] . 'static.flickr.com/' . $photo['server'] . '/' . $photo['id'] . '_' . $photo['secret'] . '_t.jpg" alt="' . $photo['title'] . '" ></li>';
}
echo '</ul>';