Definitions of PHP variables, variable variables, variable references, destruction methods _php tips

Source: Internet
Author: User
Copy Code code as follows:

<?php
$long = "Big_long_variable_name";
$ $long = "PHP"; /* Use the string stored in the variable $long as the variable name for the new variable, equivalent to $big_long_variable_name= "PHP"; */
$short =& $big _long_variable_name; /* Take variable $big_long_variable_name value assigned to variable $short, at this time $short value is "PHP", equivalent to $short=& $ $long; */
Print "01/$short is $short."; /* "/$" is an escape sequence that represents the output of a dollar sign $, hereinafter. The function of this statement is output: $short is PHP. */
Print "Long is $big _long_variable_name."; /* Output: A Long is PHP. */
?>
<br/>
<br/>
<?php $big _long_variable_name.= "rocks!"; /* Re-assign values to $big_long_variable_name. During the $big_long_variable_name, the value of the variable $big_long_variable_name at this point should be the original value ("PHP") + The New value ("rocks!") as a result of the addition of the. (point number). , that is, the variable $big_long_variable_name the current complete value is "PHP rocks!". Same */
Print "03/$short is $short"; /* Output: $short is PHP rocks! */
Print "Long is $big _long_variable_name"; /* Output: Long is PHP rocks! */
?>
<br/>
<br/>
$short is PHP rocks!
The Long is PHP rocks!
<br/>
<br/>
<?php $short. = "Programming $short"; /* Re-assign the variable $short. Because you added a. (point number) after $short, refer to the above example to analyze the value of $short. */
Print "07/$short is $short"; /* Output: Modified $short is PHP rocks! Programming PHP rocks! */
Print "Long is $big _long_variable_name"; /* Because the variable $short is assigned to programming PHP rocks!, the value of the variable $big_long_variable_name is also changed to "PHP $short" with rocks! Programming PHP rocks! ". Output of this statement: Long is PHP rocks! Programming PHP rocks! Note that if a variable with the same value is destroyed unset (), the other variable does not apply to this case and is not destroyed together. */
?>
<br/>
<br/>
$short is programming PHP rocks!
A Long is programming PHP rocks!
<br/>
<br/>
<?php $big _long_variable_name.= "Web programming $short"; /* Variable $big_long_variable_name is assigned a value, at which point its full value should be PHP rocks! Programming PHP rocks! Web Programming PHP rocks! Programming PHP rocks!. Variable $short on this time and variable $big_long_variable_name consistent. Please refer to the 5th and 10th notes for analysis respectively. */
Print "11/$short is $short"; /* Output: one PHP rocks! Programming PHP rocks! Web Programming PHP rocks! Programming PHP rocks! */
Print "Long is $big _long_variable_name";
?>
<br/>
<br/>
<?php
unset ($big _long_variable_name); /* Use unset () to destroy variable $big_long_variable_name, the variable $short will not be affected by any. */
Print "13/$short is $short"; /* Although the variable $big_long_variable_name was destroyed, the $short is not affected, and its value is still the last given PHP rocks! Programming PHP rocks! Web Programming PHP rocks! Programming PHP rocks! */
Print "Long is $big _long_variable_name."; /* Variable $big_long_variable_name has been destroyed and therefore has no value. Output:. */
Snow
?>
<br/>
<br/>
<?php $short = "No point TEST1"; /* Re-assign the variable $short. Since it was not added after $short this time, the $short current value is "no point TEST1". */
Print "15/$short is $short."; /* Output: $short is No point TEST1. */
$short = "No point TEST2 $short"; /* Re-assign the variable $short. did not add a. (dot) after $short, but referred to its own last value "no point TEST1". */
Print "16/$short is $short."; /* Output: $short is no. 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.