Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
简单的PHP语句,我无法让它工作!_Php - Fatal编程技术网

简单的PHP语句,我无法让它工作!

简单的PHP语句,我无法让它工作!,php,Php,如何让$schedule=true`和$schedule2=true工作 我知道这很容易,我忽略了一些简单的事情 以下是完整的代码: 我基本上希望schedule和schedule2正常工作,它会在我们的新闻网站上查看PHP日期并告诉它何时过期 $where = array(); $where = run_filters('also-allow', $where); if ($allow_full_story or $allow_add_comment) { $post = 'full

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

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

以下是完整的代码:

我基本上希望schedule和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;
}
你不能连续有两个。 也许是其他的,但没有人知道你的逻辑。

你不能连续有两个其他的。
也许是其他人,但没人知道你的逻辑。

你用了太多其他人的逻辑。尽量简化您的代码、用例。

您使用了太多其他代码。尽量简化您的代码、用例。

什么?你能解释一下你期望这段代码做什么,以及它实际上在做什么吗?@Tyler:看起来他正在构建一个sqlstatement@SeanJA是的,但我的意思是关于他试图使用$schedule的目的,以及他无法用它实现的效果。@OP你指的是什么?您的程序中没有$schedule=true…@eberswine:我认为此片段之前的代码可能有助于找到您遇到的问题的解决方案。什么?你能解释一下你期望这段代码做什么,以及它实际上在做什么吗?@Tyler:看起来他正在构建一个sqlstatement@SeanJA是的,但我的意思是关于他试图使用$schedule的目的,以及他无法用它实现的效果。@OP你指的是什么?您的程序中没有$schedule=true…@eberswine:我认为此片段之前的代码可能有助于找到您所遇到问题的解决方案。每个if只有1个其他代码。如果你仔细看,你会看到的。当然,代码格式是残暴的,它里面还有其他的:else{…$schedule=false;}else{if…我在Netbeans中检查了它。他每个if只有一个else。如果你仔细看,你会看到。当然,代码格式是残暴的,它里面有其他的:else{…$schedule=false;}else{如果…我在Netbeans中检查了它。