顺便说一句,PHP 的标头不起作用 html


header of php not working btw html?

<body>
<p>We hope to see you again..</p>
<?php header('Location: http://something/com'); ?>
</body>

怎么来了?我从w3school复制语法

header() 必须在发送任何实际输出之前调用,无论是通过普通 HTML 标记、文件中的空行还是从 PHP 发送。读取包含或require函数或其他文件访问函数的代码,并且在调用header()之前输出空格或空行,这是一个非常常见的错误。使用单个 PHP/HTML 文件时也存在同样的问题。

你可以做这样的事情:

<?php 
$message = "We hope to see you again..";
header('Location: http://something/com?msg='.$message);
exit;
?>

并在重定向的页面回显$_GET['msg'];中显示您的信息

前面没有空格和 heder() 函数。标头在任何输出之前。

您需要放置该页面的代码统计信息

喜欢

<?php
header("Location: http://www.example.com/"); /* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
exit;
?>