PHP variable definition, variable, variable reference, and destruction

Source: Internet
Author: User

<? Php <br/> $ long = "big_long_variable_name"; <br/> $ long = "php "; /* use the string stored in the variable $ long as the name of the new variable, equivalent to $ big_long_variable_name = "php"; */<br/> $ short = & $ big_long_variable_name; /* assign the value of $ big_long_variable_name to the variable $ short. The value of $ short is "php", which is equivalent to $ short = & $ long; */<br/> Print "01/$ short is $ short. ";/*"/$ "is an escape sequence, indicating to output a dollar sign $, the same below. The purpose of this statement is to output: 01 $ short is Php. */<br/> Print "02 long is $ big_long_variable_name. ";/* output: 02 long is Php. */<br/>?> </P> <p> <br/> </P> <p> <? PHP $ big_long_variable_name. = "rocks! ";/* Assign a value to $ big_long_variable_name again. During the value re-assignment process, because the. (point number) is added after $ big_long_variable_name, the value of the variable $ big_long_variable_name should be the original value ("php") + new value ("rocks! "), That is, the current complete value of the variable $ big_long_variable_name is" php rocks! ". The same below. */<Br/> Print "03/$ short is $ short";/* output: 03 $ short is Php rocks! */<Br/> Print "04 Long is $ big_long_variable_name";/* output: 04 Long is Php rocks! */<Br/>?> </P> <p> <br/> </P> <p> 05 $ short is Php rocks! <Br/> 06 long is Php rocks! </P> <p> <br/> </P> <p> <? PHP $ short. = "programming $ short";/* value the variable $ short again. Because. (DOT) is added to the end of $ short, please refer to the above example to analyze the value of $ short. */<Br/> Print "07/$ short is $ short";/* output: 07 $ short is Php rocks! Programming PHP rocks! */<Br/> Print "08 long is $ big_long_variable_name";/* The variable $ short is assigned a new value to programming PHP rocks !, Therefore, the value of $ big_long_variable_name is changed to "php rocks!" together with $ short! Programming PHP rocks! ". Output of this statement: 08 long is Php rocks! Programming PHP rocks! Note: If you destroy unset () for a variable with the same value, the other variable is not applicable to this situation and will not be destroyed together. */<Br/>?> </P> <p> <br/> </P> <p> 09 $ short is programming PHP rocks! <Br/> 10 long is programming PHP rocks! </P> <p> <br/> </P> <p> <? PHP $ big_long_variable_name. = "Web programming $ short";/* The variable $ big_long_variable_name is assigned a new value, and the complete value should be PHP rocks! Programming PHP rocks! WEB programming PHP rocks! Programming PHP rocks !. The value of $ short is consistent with $ big_long_variable_name. For analysis, see comments in section 5th and section 10th. */<Br/> Print "11/$ short is $ short";/* output: 11 PHP rocks! Programming PHP rocks! WEB programming PHP rocks! Programming PHP rocks! */<Br/> Print "12 long is $ big_long_variable_name"; <br/>?> </P> <p> <br/> </P> <p> <? Php <br/> unset ($ big_long_variable_name);/* use unset () to destroy the variable $ big_long_variable_name. The variable $ short will not be affected. */<Br/> Print "13/$ short is $ short";/* although the variable $ big_long_variable_name is destroyed, $ short is not affected, its value is still the last PHP rocks assigned! Programming PHP rocks! WEB programming PHP rocks! Programming PHP rocks! */<Br/> Print "14 long is $ big_long_variable_name.";/* The variable $ big_long_variable_name has been destroyed and therefore has no value. Output: 14 long is. */<br/> snow; <br/>?> </P> <p> <br/> </P> <p> <? PHP $ short = "No point test1";/* value the variable $ short again. Because no. is added after $ short this time, the current value of $ short is "No point test1 ". */<Br/> Print "15/$ short is $ short. ";/* output: 15 $ short is no point test1. */<br/> $ short =" No point Test2 $ short ";/* assign a value to the variable $ short. No. is added after $ short, but its last value "No point test1" is referenced ". */<Br/> Print "16/$ short is $ short.";/* output: 16 $ short is no point Test2 no point test1 .*/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.