< span="">
< span=""> < span=""> =< span=""> " why"< span=""> = "What" < span="">
ChangeName (); < span="">< span=""> . "
"< span="">?>
The result of executing the code is: My name was why, not the ChangeName () after performing the What. Analyze the reason, because the function body changename within the $name variable is set to local variables by default, $name scope is within the changename. So, modify the code and add the global variables as follows:
< span="">< span="">< span="">< span=""> < span=""> =< span=""> " why"< span=""> = "What" < span="">
ChangeName (); < span="">< span=""> . "
"< span="">?>
Attention:< span="">
The result of defining a global variable is still my name is why, which surprises me. It turns< span="">out, "that is, when a function refers to an external variable, it can be declared within a function through global, so that the variable can be used in the function (equivalent to passing in as a parameter). Then, modify the code again:
< span="">= < span=""> < span=""> "Why" < span=""> < span=""> < span=""> < span=""> < span=""> = "What "< span=""> . < span=""> < span=""> "
"< span="">?>
The results of this operation are: My name is what, description< span="">
< span="">= < span=""> < span=""> "Why" < span=""> < span=""> < span=""> < span=""> < span=""> = "What < span=""> " < span=""> < span=""> < span=""> = " where".< span=""> < span=""> < span=""> "
"< span="">?>
< span="">
< span="">< span="">
< span="">
< span="">=< span="">"< span="">< span="">Why" [' name '] = "What" < span=""> < span="">< span="">< span=""> . "
"< span="">?>
< span="">
< span="">
!--? = 1
= 2
[' var2 '] = &[' var1 ' < Span echo< span> . "
" = 1 = 2 < Span Test2 () {span> , = & . "
" ?>
The value of the
$GLOBALS is always available in PHP. Another example:
< span="">=< span="">1< span="">([' var1 '< span="">< span="">< span=""> < span="">< span="">< span=""> . "
" < span=""> < span=""> = 1 < span=""> < span=""> < span=""> < span="">< span="">< span="">< span="">(< span="">< < span="">/c40>< span="">?>< span="">< span="">
http://www.bkjia.com/PHPjc/749824.html www.bkjia.com true http://www.bkjia.com/PHPjc/749824.html techarticle ? = "why" = "What" changename (); "My name is" ... " br/"? The result of executing the code is: My name was why, not the ChangeName () after performing the What. Analyze the reason, this is because the function body ...