I’m curious to know why the following code behaves differently?
The following does not work:
$_variable &= global $_global;
echo $_variable;
The following works:
global $global;
$_variable &= $_global;
echo $_variable;
?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Think of the
globalkeyword more like a verb than an adjective. Your first example says “reference assign the global known as $_global to $_variable”. Butglobalis not an adjective. The second example, which is correct, says to php, “Treat $_global as a global”, or “global-ify $_global”, and then make the assignment.