PHP正在构建重定向错误(已关闭)

时间:2013-11-12 18:58:44

标签: php

我的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");
}
}

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

1 个答案:

答案 0 :(得分: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']);
  }