The content shared with you in this article is about how PHP variables are defined and how PHP works. The content is of great reference value. I hope it can help friends in need.
1. Variable definition:
What we usually learn is that a variable represents an "identifier" for the storage space and the data in it.
The variable name points to the variable value
More deeply, the variable points to an area of memory
2. The working principle of variables, through drawing analysis method-memory space
$val){ $val = &$data[$key]; } 问:最终$data的值是多少? */ $data = ['a','b','c']; foreach($data as $key=>$val){ $val = &$data[$key]; print_r($data); } /* 1.$key = 0, $val = 'a', $val = &$d[0] =>'a' $data = ['a','b','c']; 2.$key = 1, $val = 'b', =>$d[0] $val = &$d[1] =>'b' $data = ['b','b','c']; 1.$key = 2, $val = 'c', =>$d[1] $val = &$d[2]=>'c' $data = ['b','c','c']; */
Related recommendations:
How to use PHP to implement the download function
The above is the detailed content of How are PHP variables defined and how does PHP work?. For more information, please follow other related articles on the PHP Chinese website!