Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.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头不转发ie9_Php - Fatal编程技术网

php头不转发ie9

php头不转发ie9,php,Php,除了ie9之外,我使用了以下在所有浏览器中都能完美工作的方法 $result = mysql_query("SELECT u_id, from users where (id = '$userID')",$db); $item = mysql_fetch_row($result); $how_many = mysql_num_rows($result); // if not a user send to reg if ($how_many < 1){ header("Locatio

除了ie9之外,我使用了以下在所有浏览器中都能完美工作的方法

$result = mysql_query("SELECT u_id, from users where (id = '$userID')",$db); 
$item = mysql_fetch_row($result);

$how_many = mysql_num_rows($result);

// if not a user send to reg
if ($how_many < 1){ 
header("Location: /pages/registration");
} 
$result=mysql\u查询(“从用户中选择u\u id,其中(id='$userID')”,$db);
$item=mysql\u fetch\u行($result);
$how\u many=mysql\u num\u行($result);
//如果不是用户,则发送到注册表
如果($多少<1){
标题(“位置/页面/注册”);
} 
它只是不转发-头函数什么也不做-但是,如果我将最后一块代码更改为下面的内容,它就可以工作了

if ($how_many < 1){ 
header("Location: /pages/registration");
// added echo for ie9
echo "<br /><br /><br /><br />here i am ";
} 
if($how_many<1){
标题(“位置/页面/注册”);
//增加了ie9的回声
回声“




我在这里”; }

我无法理解这其中的任何逻辑原因,我是否遗漏了什么?

只要您在重定向后不需要再做任何处理,您应该在发送
位置
标题后:

if ($how_many < 1){ 
    header("Location: /pages/registration");
    exit;
} 
if($how_many<1){
标题(“位置/页面/注册”);
出口
} 

通过退出或回显,缓冲区由web浏览器刷新,IE9在采取行动之前等待

以下工作也将起作用:

header('Location: /page');
flush();

我建议在调用header函数后使用exit/die,以防止不必要的代码/资源被利用。

您确定上面没有空格吗?您也删除了它以进行成功的检查。错误日志中有任何错误吗?上面的空白处有否和否-将导致一个PHP错误(无法发送标题),其中没有。是的,这当然是一种解决方法。但我想指出的是,“echo”命令也不会终止php进程,仍然正确处理了它的头。算了吧。)