Definition of PHP variables, mutable variables, variable references, and destruction methods_PHP tutorial

WBOY
Release: 2016-07-13 17:18:17
Original
710 people have browsed it

Copy code The code is as follows:

$long="big_long_variable_name";
$$long= "PHP"; /* Use the string stored in the variable $long as the variable name of the new variable, which is equivalent to $big_long_variable_name="PHP"; */
$short=& $big_long_variable_name; /* Get the variable $big_long_variable_name The value of is assigned to the variable $short. At this time, the value of $short is "PHP", which is equivalent to $short=& $$long; */
print "01 /$short is $short."; /* "/ $" is an escape sequence, indicating that a dollar sign $ is output, the same below. The function of this statement is to output: 01 $short is PHP. */
print "02 Long is $big_long_variable_name."; /* Output: 02 Long is PHP. */
?>
< br />


print "03 /$short is $short"; /* Output: 03 $short is PHP rocks! */
print "04 Long is $big_long_variable_name"; /* Output: 04 Long is PHP rocks ! */
?>




05 $short is PHP rocks!
06 Long is PHP rocks!
< ;br />


print "07 /$short is $short"; /* Output: 07 $short is PHP rocks! Programming PHP rocks! */
print "08 Long is $big_long_variable_name"; /* Due to variable $ short is reassigned to Programming PHP rocks!, so the value of variable $big_long_variable_name is also changed to "PHP rocks! Programming PHP rocks!" together with $short. Output of this statement: 08 Long is PHP rocks! Programming PHP rocks! Note that if a variable with the same value is destroyed by unset(), the other variable does not apply to this situation, that is, it will not be destroyed together. . */
?>




09 $short is Programming PHP rocks!
10 Long is Programming PHP rocks!




print "11 /$short is $short"; /* Output: 11 PHP rocks!Programming PHP rocks!Web Programming PHP rocks!Programming PHP rocks! */
print "12 Long is $big_long_variable_name" ;
?>




unset($big_long_variable_name); /* Use unset() to destroy the variable$ big_long_variable_name, the variable $short will not be affected in any way. */
print "13 /$short is $short"; /* Although the variable $big_long_variable_name is destroyed, $short is not affected, and its value is still the most recently assigned PHP rocks!Programming PHP rocks!Web Programming PHP rocks! Programming PHP rocks! */
print "14 Long is $big_long_variable_name."; /* The variable $big_long_variable_name has been destroyed, so it has no value. Output: 14 Long is. */
snow; TEST1"; /* Re-assign the variable $short. Since there is no . (dot) added after $short this time, the current value of $short is "No point TEST1". */
print "15 /$short is $short."; /* Output: 15 $short is No point TEST1. */
$short="No point TEST2 $short"; /* Re-align the variables $short assignment. No . (dot) is added after $short, but its latest value "No point TEST1" is quoted. */
print "16 /$short is $short."; /* Output: 16 $short is No point TEST2 No point TEST1. */

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/621676.htmlTechArticleCopy the code as follows: ?php $long="big_long_variable_name"; $$long="PHP";/* Use the string stored in the variable $long as the variable name of the new variable, which is equivalent to $big_long_variable_name...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!