Why $ GLOBALS [a] generates the variable a, $ _ COOKIE [a] does not generate cookiea; $ GLOBALS ['A'] = 1; the $ a = 1 variable is automatically generated. if I use xdebug, you can directly echo $ a for output;
$ _ COOKIE ['A] = 1; but only one element is added to the array, and no cookie is added;
Question 1:
Echo 1111;
Setcookie ('A', 1 );
$ _ COOKIE ['name']
?>
When PHP executes this script, what content is first sent to the user's browser? Is setcookie ('A', 1); $ _ COOKIE ['name'] or 1111;
Cookie is the mime header. The PHP compiler analyzes the code and finds that there is a setcookie. First, it sends the setcookie header to the browser and then outputs other content?
Question 2: Why does $ GLOBALS ['A'] = 1 generate the variable $ a, $ _ COOKIE ['A] = 1 without generating cookie a, even if it is refreshed;
Thank you for your explanation;
Reply to discussion (solution)
Because? You? Yes? Set? Period ??.
Setcookie ('A', 1, time () + 3600 );
1. setcookie ('A', 1 );
Add a Set-Cookie: a = 1 in the HTTP header sent to the client.
2. the $ _ COOKIE ['A] = 1 is not interpreted as setcookie ('A', 1), which is the negligence of php, resulting in inconsistent styles.
However, it is also difficult for the general interface to uniformly process multiple setcookie parameters.