通过php.net网站,它有一个标题的例子,说会给我错误.我复制了它,并在WAMP上执行,但它没有向我显示任何错误,但确实重定向到该网站.
<html>
<?php
/* This should give an error (but it doesn't!). Note the output
* above, which is before the header() call */
header('Location: http://www.example.com/');
?>
Run Code Online (Sandbox Code Playgroud)
只是想知道,如果它在我的WAMP上是正确的行为,或者它是一个错误,或者我在php.ini文件中有任何特定的设置活动,这使得这个工作!!! 如果有人需要我的php.ini复制在这里,请告诉我!!
谢谢,Tanmay
听起来你已经启用了output_buffering。
http://php.net/manual/en/outcontrol.configuration.php
标准配置会出错,因为数据已经输出,并且标头需要先出现。输出缓冲允许标头在其他输出之后出现在代码中,但由于缓冲区,它仍然会首先输出标头。