PHP标头函数意外行为

时间:2016-06-29 13:43:34

标签: php header

我正在测试下面的代码,其中在我调用header函数之前发送了<html>标记。理想情况下,我应该得到'Headers already sent'错误。但令我惊讶的是,该页面被重定向到google.com。知道为什么会这样吗?

<html>
<?php
/* This will give an error. Note the output
 * above, which is before the header() call */
header('Location: http://www.google.com/');
exit;
?>

0 个答案:

没有答案