1

我的 php 脚本遇到了这个奇怪的问题。

我有

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING 
in simpleTest.php on line 82  

我不确定为什么我的代码不起作用。

<?php
    foreach ( $response->getPods() as $pod ) {
?>
      <tr>
        <td>
          <h3><?php echo $pod->attributes['title']; ?></h3>   //line 82..this gives me error...


   <?php
           foreach ( $pod->getSubpods() as $subpod ) {
     ?>
  <img src="<?php echo $subpod->image->attributes['src']; ?>">  //this would gives me error too...
              <hr>
    <?php
            }
    ?>

谢谢您的帮助!

4

2 回答 2

2

您缺少外部 foreach 循环的右花括号。

于 2012-10-14T19:04:11.597 回答
1
<?php foreach ( $response->getPods() as $pod ) { 
      echo "<tr><td><h3>".$pod->attributes['title']."</h3>";
      foreach ( $pod->getSubpods() as $subpod ) {
          echo "<img src='".$subpod->image->attributes['src']."'><hr>";
      }
}?>

Coderabbi 是对的,缺少一个卷曲。

于 2012-10-14T19:08:10.433 回答