<?php
$_POST["test_message"] = "Hello, world";
header("Location: http://localhost/file_2.php");
?>
这是file_2.php文件。
<html>
<head>
</head>
<body>
<?php
if (!(isset($_POST["test_message"])))
echo "Test message is not set";
else
echo $_POST["test_message"];
?>
</body>
</html>
输出是Test message is not set
这使我想知道是否可以写入$_POST,然后我想知道这样做是否是不好的做法。我应该让带有提交按钮和method=post的表单为我写入$_POST,还是可以将数据写入$_POST以在文件之间传递数据?