为什么输出后setCookie有效?

问题描述

我是PHP新手。 我有这样的代码

<!doctype html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
    <Meta name="viewport"
          content="width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0">
    <Meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>

<p>Lean PHP</p>

<?PHP setCookie("name","Bob"); ?>
<?= $_COOKIE['name']; ?>
</body>
</html>

我编写此代码的目的是失败。我想检查在输出调用setCookie()会收到什么样的错误消息。 但这不会给我任何错误,并且运行正常。 我的理解是错误的,当我在输出调用setCookie()时,它会失败吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)