简单的PHP声明,我无法让它工作!

时间:2010-04-24 00:50:11

标签: php

如何让$ schedule = true`和$ schedule2 = true工作?

我知道这很容易,我忽视了一些简单的事情!

以下是完整代码:

我基本上希望日程安排和schedule2工作(它查看PHP日期并告诉它何时在我们的新闻网站上过期!)

$where = array();
$where = run_filters('also-allow', $where);

if ($allow_full_story or $allow_add_comment) {
    $post = 'full';

    if ($title){
        $where[] = "url = $title";
    } elseif ($time){
        $where[] = "date = $time";
    } elseif ($id){
        $where[] = "id = $id";
    }
} else {
    $post = 'short';

    if (!$is_logged_in or $is_logged_in and $member['level'] == 4) {
        $where[] = 'hidden = 0';
        $where[] = 'and';
    }

    if ($user or $author) {
        $where[] = 'author = '.($author ? $author : $user);
        $where[] = 'and';
    }

    if ($year and !$month) {
        $where[] = 'date > '.@mktime(0, 0, 0, 1, 1, $year);
        $where[] = 'and';
        $where[] = 'date < '.@mktime(23, 59, 59, ($year == date("Y") ? date("n") : 12), ($year == date("Y") ? date("d") : 31), $year);
    } elseif ($year and $month and !$day) {
        $where[] = 'date > '.@mktime(0, 0, 0, $month, 1, $year);
        $where[] = 'and';
        $where[] = 'date < '.@mktime(23, 59, 59, $month, (($year == date("Y") and $month >= date("n")) ? date("d") : 31), $year);
    } elseif ($year and $month and $day) {
        if($year == date("Y") and $month >= date("n") and $day >= date("d")) {
            $where[] = 'hidden = 2';
        }
        else {
            $where[] = 'date > '.@mktime(0, 0, 0, $month, $day, $year);
            $where[] = 'and';
            $where[] = 'date < '.@mktime(23, 59, 59, $month, $day, $year);
        }
    }
    else {
    if ($schedule) {
        $where[] = 'date > '.(time() + $config_date_adjust * 60 - 432000);
    }
    else {
        $where[] = 'date < '.(time() + $config_date_adjust * 60);
    }
    $schedule = false;
}
else {
    if ($schedule2) {
        $where[] = 'date > '.(time() + $config_date_adjust * 60 - 86400);
    }
    else {
        $where[] = 'date < '.(time() + $config_date_adjust * 60);
    }
    $schedule2 = false;
}

3 个答案:

答案 0 :(得分:7)

你不能连续2 else。 也许elseif,但没有人知道你的逻辑。

答案 1 :(得分:1)

答案 2 :(得分:0)

你使用太多别的了。尝试简化代码,使用CASE。