This question already has an answer here: How to make a redirect in PHP? 27 answers Try using the header() function as so: if ($num == 1) { header("Location: http://www.example.com"); } Obviously change http://www.example.com to your location of choice and place it above any HTML in your page otherwise you will get a headers already set error. With the above in mind you would need to
这个问题在这里已经有了答案: 如何在PHP中进行重定向? 27个答案 尝试使用header()函数,如下所示: if ($num == 1) { header("Location: http://www.example.com"); } 很明显,将http://www.example.com更改为您选择的位置,并将其放在页面中的任何HTML上方,否则您将得到一个标题已设置的错误。 考虑到上述情况,您需要重新安排您的代码,如下所示: <?php // takes the variables from action script an
This question already has an answer here: How to make a redirect in PHP? 27 answers Yes, you would use the header function. header("Location: http://www.yourwebsite.com/user.php"); /* Redirect browser */ exit(); It is a good practice to call exit() right afterwords so that code below it does not get executed. Also, from the documentation: Remember that header() must be called before an
这个问题在这里已经有了答案: 如何在PHP中进行重定向? 27个答案 是的,你会使用标题功能。 header("Location: http://www.yourwebsite.com/user.php"); /* Redirect browser */ exit(); 调用exit()后缀是一个很好的习惯,这样它下面的代码就不会被执行。 另外,从文档: 请记住,必须在发送任何实际输出之前调用header(),或者通过普通的HTML标记,文件中的空行或来自PHP。 使用include()或require()函数或
This question already has an answer here: How to fix “Headers already sent” error in PHP 11 answers Try removing the closing php tag '?>' from your script. That might help. More information on that here See if there is blank space before very first <?php of your page. if so then Remove space
这个问题在这里已经有了答案: 如何解决PHP 11中的“Headers already sent”错误 尝试从您的脚本中移除关闭的php标记'?>'。 这可能有帮助。 关于这方面的更多信息 在页面的第一个<?php之前查看是否有空格。 如果是的话删除空间
This question already has an answer here: How to fix “Headers already sent” error in PHP 11 answers This type of problem is caused when you use header after you write in your page. I assume you code might look like :: <html> <head> <title> title </title> ......... </head> <body> ..... <?php header() // checking so
这个问题在这里已经有了答案: 如何解决PHP 11中的“Headers already sent”错误 这种类型的问题是在您写入页面后使用标题时引起的。 我假设你的代码可能看起来像:: <html> <head> <title> title </title> ......... </head> <body> ..... <?php header() // checking some header ?> ..... </body> </html>
This question already has an answer here: How to fix “Headers already sent” error in PHP 11 answers cookies in HTTP will be transferred using the headers. setcookie() therefore is just a wrapper around header() and cannot being used if there were already output in that script. I guess that the output is an error message triggered by the mysql_* functions or whitespace|content before the op
这个问题在这里已经有了答案: 如何解决PHP 11中的“Headers already sent”错误 HTTP中的Cookie将使用标题进行传输。 因此, setcookie()只是header()一个包装,如果该脚本中已经输出了,则不能使用它。 我猜测输出是在开始<?php标记之前由mysql_*函数或whitespace引发的错误消息 我有类似的问题。原因是你可能在php标签之前有一个空白区域。删除空间,你很好去。 使用ob_start(); 在php标签后 $ user = mysql_r
Possible Duplicate: “Warning: Cannot modify header information - headers already sent by” error setcookie, Cannot modify header information - headers already sent I have this code to set cookie : if (!isset($_COOKIE["CorkIU"])) { setcookie("CorkIU", 2dd2ee3aUgsvoRye, time()+60*60*24*365, "/"); } I have added this code in layout.php file The first lines from layout.php file is <!DOCT
可能重复: “警告:不能修改标题信息 - 已由”错误发送的标题“ setcookie,不能修改标题信息 - 已经发送的标题 我有这个代码来设置cookie: if (!isset($_COOKIE["CorkIU"])) { setcookie("CorkIU", 2dd2ee3aUgsvoRye, time()+60*60*24*365, "/"); } 我已经在layout.php文件中添加了这个代码 layout.php文件的第一行是 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/
Are ob_start / ob_get_clean() considered bad practice by php programmers in general? Are there any disadvantages of output buffering? It's actually a good practice. Speed up data transfer Output buffering in some circumstances is almost mandatory. With PHP as soon as you output something back to the user, headers are sent. Therefore if you get partway through processing a page and so
ob_start / ob_get_clean()被一般的php程序员认为是不好的做法吗? 输出缓冲是否有缺点? 这实际上是一个好习惯。 加快数据传输 在某些情况下输出缓冲几乎是强制性的。 只要你输出一些东西返回给用户,就会发送头文件。 因此,如果您在处理页面过程中遇到某种情况,并且需要发送标头,则只有在缓冲打开的情况下才能发送。 否则,你会得到可怕的“不能修改标题信息 - 标题已经发送”。 有些人会告诉你,你不应该这样编
I have read quite a bit of material on Internet where different authors suggest using output buffering. The funny thing is that most authors argument for its use only because it allows for mixing response headers with actual content. Frankly, I think that responsible web applications should not mix outputting headers and content, and web developers should look for possible logical flaws in thei
我在互联网上阅读了很多资料,其中不同的作者建议使用输出缓冲。 有趣的是,大多数作者认为它的使用只是因为它允许将响应头与实际内容混合在一起。 坦率地说,我认为负责任的Web应用程序不应混合输出标题和内容,Web开发人员应该在其脚本中寻找可能的逻辑缺陷,从而在输出生成后发送标题。 这是我对ob_*输出缓冲API的第一个参数。 即使为了获得这么少的便利 - 混合标题和输出 - 这不是一个足够好的理由来使用它,除非需要快
I have a script which outputs mysql cell data. The "content" cell contains text output, which is of varied length. When the contents of the "content" cell are small (lets say, a few lines of text), everything works fine. However, when the output reaches several paragraphs or more, I get the 'headers already sent' error. Does it depend on the output length? Where
我有一个输出mysql单元格数据的脚本。 “内容”单元格包含文本输出,其长度各不相同。 当“内容”单元格的内容很小(可以说,几行文字)时,一切正常。 但是,当输出达到多个段落或更多时,我会收到'标题已发送'错误。 它取决于输出长度吗? 我在哪里可以阅读更多关于它的内容 我在SO上找到的答案没有提到这种输出长度依赖性。 44: echo " 45: <p>".$article['content']."</p> 46: "; 如
I get header problem while I use ob_start() in the beginning of a page and ob_end_flush() at the end. Because I use header function after some query execution. ob_start(); include_once("header.php"); global $db; $countstmt="SELECT COUNT(*) FROM tbl_lib_hours dh WHERE book_id IN(SELECT book_id FROM tbl_book WHERE user_id=".$_SESSION['uid'].") "; $delHourExist=$db->query($countstm
我在页面的开始处使用ob_start()并在最后使用ob_end_flush()时遇到标题问题。 因为我在一些查询执行后使用头函数。 ob_start(); include_once("header.php"); global $db; $countstmt="SELECT COUNT(*) FROM tbl_lib_hours dh WHERE book_id IN(SELECT book_id FROM tbl_book WHERE user_id=".$_SESSION['uid'].") "; $delHourExist=$db->query($countstmt); if($delHourExist){ header("location:edi