This question already has an answer here:
I have code like this:
<!DOCTYPE html>
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$cookie_name = "user";
$cookie_value = "John Doe";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day
?>
<html>
<body>
<?php
if (!isset($_COOKIE[$cookie_name])) {
echo "Cookie named '" . $cookie_name . "' is not set!";
} else {
echo "Cookie '" . $cookie_name . "' is set!<br>";
echo "Value is: " . $_COOKIE[$cookie_name];
}
?>
</body>
</html>
and from my knowlege it should return warning
Cannot modify header information - headers already sent by
As in this question How to fix "Headers already sent" error in PHP but I don't get any warning and the cookie is set. Why is that? Is php added some kind of cache and now you can send headers after the text is sent? I'm using php 5.6.11.
</div>