0

我的 PHP 正在建设中的代码有问题。这是我的代码:
PHP: (init.php)

$date = new DateTime();
if ($date->format('Y-m-d H:i:s') < $row['ending']) {
construct();
}

构造();功能:(general.php)

$current_file = explode('/', $_SERVER['SCRIPT_NAME']);
$current_file = end($current_file);

function construct() {
$allow = array("MY IP");
if (!in_array ($_SERVER['REMOTE_ADDR'], $allow)) {
header ("Location: construct");
}
}

我的错误是它没有重定向它。请帮忙,谢谢!

4

1 回答 1

0

尝试通过执行以下操作进行调试:

$date = new DateTime();
$curdate = $date->format('Y-m-d H:i:s');
if ($curdate < $row['ending']) {
  construct();
  }
else {
  echo "Not redirecting properly. Start: " . $curdate . " end: " . $row['ending'];
  // If you are using exceptions to handle errors (as you should),
  // change the line of code above for:
  // throw new Exception("Not redirecting properly. Start: " . $curdate . " end: " . $row['ending']);
  }
于 2013-11-12T19:11:58.250 回答