php header函数的问题,比如说header之前不能有实际的输出
天蓬老师
天蓬老师 2017-04-10 14:37:33
0
4
578

原文链接:PHP Header用于页面跳转要注意的几个问题总结php技巧脚本之家

搜到了这篇文章,开头就说了三个关于PHP header()的注意事项,

  1. location和“:”号间不能有空格,否则会出错。
  2. 在用header前不能有任何的输出。
  3. header后的PHP代码还会被执行。

第3点测试结果无误。

第1点,测试大概是指的 header('Location: http://segmentfault.com/');Location: 不能有空格吧,但其实是可以有的。

主要是第2点,header前不能有任何的输出有疑问,我测试了下面的代码,能成功跳转啊:

<html>asdf</html>
<?php
header('Location : http://segmentfault.com/');

到底要怎样测试才能报错呢?php手册上的“Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP”到底是啥意思?

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(4)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!