PHP 标头位置重定向不起作用 - 为什么? [英] PHP header location-redirect doesn't work - why?

查看:28
本文介绍了PHP 标头位置重定向不起作用 - 为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的文件.我想让它重定向,但没有任何反应.为了检查发生了什么,我在标题部分之前添加了一个 echo.

Here's my file. I want to make it redirect, but nothing happens. To check out what is going on, I added an echo before the header part.

它既不会抛出错误也不会重定向到 index.php.怎么了?我已经打开/关闭输出缓冲,但没有任何东西使它重定向.我能做什么?

It neither throws an error or redirect to index.php. What is wrong? I have turned output buffering on/off, but nothing makes it redirect. What can I do?

<?
error_reporting(E_ALL);
echo 'This is an error';

header("Location: login.php");
die();
?>

谢谢

推荐答案

我提醒自己,我在实际测试环境中安装了 xDebug,经过谷歌搜索后,我发现了这个站点:http://bugs.xdebug.org/view.php?id=532

I reminded myself that I had xDebug installed on the actual test environment and after googling it, I found this site: http://bugs.xdebug.org/view.php?id=532

因此,我将下载最新版本的 xDebug 并相应地为新文件更改 php.ini,一切都变得很完美.正在发送标头 - 重定向已完成并显示错误.

So I'll downloaded the last version of xDebug and changed the php.ini accordingly for the new file and everything works out like a charm. Headers are being sent - the redirecetion is done and errors are displayed.

感谢大家的帮助!

这篇关于PHP 标头位置重定向不起作用 - 为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆