PHP strtotime 问题,导致错误
PHP strtotime issue, causing error
if(!empty($maintenance_options['disable'])) {
$currentDate = date("Y-m-d H:i:s", strtotime(date("Y-m-d") . date("H:i:s")));
$nodate = $maintenance_options['disable'], strtotime(date("Y-m-d") . date("H:i:s"));
if($currentDate > $nodate) {
echo 'if';
} else {
echo 'else';
}
}
我有这个奇怪的错误:
Parse error: syntax error, unexpected ',' on line 53
第 53 行是
$nodate = $maintenance_options['disable'], strtotime(date("Y-m-d") . date("H:i:s"));
不过那条线好像没问题吧?怎么了?
这个问题有点难理解,但我想我知道在问什么。看起来 $currentDate 需要设置为当前 PHP 时间,$nodate 需要设置为 $maintenance_options['disable'] 的时间值。如果这是真的,下面的代码应该可以工作。
$currentDate = time();
$nodate = strtotime($maintenance_options['disable']);
if(!empty($maintenance_options['disable'])) {
$currentDate = date("Y-m-d H:i:s", strtotime(date("Y-m-d") . date("H:i:s")));
$nodate = $maintenance_options['disable'], strtotime(date("Y-m-d") . date("H:i:s"));
if($currentDate > $nodate) {
echo 'if';
} else {
echo 'else';
}
}
我有这个奇怪的错误:
Parse error: syntax error, unexpected ',' on line 53
第 53 行是
$nodate = $maintenance_options['disable'], strtotime(date("Y-m-d") . date("H:i:s"));
不过那条线好像没问题吧?怎么了?
这个问题有点难理解,但我想我知道在问什么。看起来 $currentDate 需要设置为当前 PHP 时间,$nodate 需要设置为 $maintenance_options['disable'] 的时间值。如果这是真的,下面的代码应该可以工作。
$currentDate = time();
$nodate = strtotime($maintenance_options['disable']);