错误期望endforeach语句

时间:2015-08-23 17:45:55

标签: php

我正在运行以下代码,并在endforeach语句的开头获取错误期望语句。

<?php foreach($lessons as $lesson) ; ?>
    <h1><?=$lesson;  ?></h1>
<?php endforeach ;?>

4 个答案:

答案 0 :(得分:2)

<?php foreach($lessons as $lesson) ; ?>
                                   ^ should be a :

答案 1 :(得分:1)

<?php foreach($lessons as $lesson) ?>

  <h1> <?php=$lesson;  ?></h1>

没有
    ; or :是必需的

类似于: -

    <!DOCTYPE html>
    <html>
    <body>

    <?php 
    $colors = array("red", "green", "blue", "yellow"); 

    foreach ($colors as $value) {
       echo "$value <br>";
    }
    ?>   

    </body>
    </html>

答案 2 :(得分:0)

格式应该是这样的。 foreach():

<?php foreach($lessons as $lesson):?>
   <h1><?=$lesson; ?></h1>
<?php endforeach ;?>

答案 3 :(得分:0)

不要在PHP和HTML之间不断切换,为什么不这样写: -

if(f.getName().toLowerCase().contains("blah")) {
    Object arr = f.get(id);
    System.out.println("Name: "+f.getName() +" Value:"+Array.get(arr, 1));
}