dpgf42422 2014-09-17 22:18
浏览 47
已采纳

PHP语法问题 - 如果语句后跟foreach循环

I am having some trouble with a syntax issue, can someone help me identify the problem? It's an if statement followed by a foreach loop:

$start_date = strtotime('2006-01-01');
$end_date = strtotime('2006-12-31');

if ($item->date >= $start_date && <= $end_date) {

foreach (expression) { 
     statement;
}

I get: Parse error: syntax error, unexpected T_IS_SMALLER_OR_EQUAL for:

if ($item->date >= $start_date && <= $end_date) {

Thoughts, suggestions? Thanks!

  • 写回答

1条回答 默认 最新

  • duanji4449 2014-09-17 22:20
    关注

    try

    if ($item->date >= $start_date && $item->date <= $end_date) {
    // …
    

    Otherwise, the second condition is incomplete.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?