PHP variable definition, variable, variable reference, destruction method _ PHP Tutorial

Source: Internet
Author: User
PHP variable definition, variable, variable reference, and destruction method. Copy the code as follows :? Php $ longbig_long_variable_name; $ longPHP; * Use a string stored in the variable $ long as the variable name of the new variable, equivalent to $ big_long_variable_name The code is as follows:


$ Long = "big_long_variable_name ";
$ Long = "PHP";/* use the string stored in the variable $ long as the name of the new variable, equivalent to $ big_long_variable_name = "PHP ";*/
$ Short = & $ big_long_variable_name;/* assign the value of $ big_long_variable_name to the variable $ short. The value of $ short is "PHP ", equivalent to $ short = & $ long ;*/
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 .*/
Print "02 Long is $ big_long_variable_name.";/* output: 02 Long is PHP .*/
?>




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!




Print "07/$ short is $ short";/* output: 07 $ short is PHP rocks! Programming PHP rocks! */
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. */
?>




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. */
Print "13/$ short is $ short";/* Although the variable $ big_long_variable_name is destroyed, $ short is not affected and its value is still the PHP rocks that was last granted! 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 and therefore has no value. Output: 14 Long is .*/
Snow;
?>




Print "15/$ short is $ short.";/* output: 15 $ short is No point TEST1 .*/
$ Short = "No point TEST2 $ short";/* value the variable $ short again. No. is added after $ short, but its last value "No point TEST1" is referenced ". */
Print "16/$ short is $ short.";/* output: 16 $ short is No point TEST2 No point TEST1 .*/

The http://www.bkjia.com/PHPjc/621676.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/621676.htmlTechArticle code is as follows :? Php $ long = "big_long_variable_name"; $ long = "PHP";/* use a string in the $ long variable as the variable name of the new variable, equivalent to $ big_long_variable_name...

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.