PHP header Location 在 HTML 中间工作

标签 php html apache header location

我在理解 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/

相关文章:

php - 循环插入查询有效一次,但之后无效

javascript - 如何将js变量传递给php变量?

java - 游戏框架中日志的位置更改

Apache regex -301 重定向以消除 url 路径中的重复项

apache 虚拟主机提供不正确的证书

php - ZF : How to add default prefix path to form elements so I don't have to set it everytime?

php - AJAX 调用未发送成功响应

javascript - 获取在语义 ui 中选中的 radio 值

html - 在 html 中编码表格形式

javascript - Chrome webkitStorageInfo.requestQuota