我在理解 header("Location: http://www.google.com/");
的方式时遇到问题可以在 HTML 页面的中间工作 <body>
.
由于 HTML 输出标题已经发送,在 <?php ... ?>
之前,不应该出现错误吗?部分开始。
我指的是警告 Cannot modify header information - headers already sent by...
我希望得到。
我正在本地 PHP 开发环境 (Apache/2.2.15 (Win32) PHP/5.3.2) 上测试它。
这是一个例子:
<html>
<head>
</head>
<body>
<?php header("Location: http://www.google.com/"); ?>
</body>
</html>
有什么想法吗?谢谢。
最佳答案
是因为output buffering ...
关于PHP header Location 在 HTML 中间工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3037199/