Home  >  Article  >  Backend Development  >  What does the & symbol in php syntax mean?

What does the & symbol in php syntax mean?

藏色散人
藏色散人Original
2019-10-09 09:51:006894browse

What does the & symbol in php syntax mean?

What does the & symbol in php syntax mean?

In PHP syntax, the & symbol is not used very much, but it also needs to be understood and mastered. Specifically, this single & symbol represents reference assignment

Create a new PHP document and define a variable, example:

$fruit = 'cherry';

What does the & symbol in php syntax mean?

Use the "&" symbol to create a reference variable, example:

$quote = &$fruit;

What does the & symbol in php syntax mean?

Print the values ​​​​of two variables, example:

echo '$quote='.$quote;
echo &#39;<br />&#39;;
echo &#39;$fruit=&#39;.$fruit;

What does the & symbol in php syntax mean?

Save the above content, view and print in the browser,

What does the & symbol in php syntax mean?

Modify the value of any variable and print again. The values ​​of both variables have changed.

So the reference assignment can be understood as an alias of a variable. For example ($quote is $ Alias ​​of fruit)

Example:

$quote = 'garpe';
echo &#39;$quote=&#39;.$quote;
echo &#39;<br />&#39;;
echo &#39;$fruit=&#39;.$fruit;

What does the & symbol in php syntax mean?

Save the above content and view the print preview again

What does the & symbol in php syntax mean?

Notes

Referenced and referenced variables are also called memory communities.

For more PHP knowledge, please visit PHP Chinese website!

The above is the detailed content of What does the & symbol in php syntax mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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
Previous article:How to use php delimiterNext article:How to use php delimiter