Home > Backend Development > PHP Tutorial > PHP value assignment and address assignment usage example analysis_PHP tutorial

PHP value assignment and address assignment usage example analysis_PHP tutorial

WBOY
Release: 2016-07-13 09:49:05
Original
843 people have browsed it

Analysis of usage examples of PHP assignment by value and assignment by address

This article explains the usage of PHP assignment by value and assignment by address. Share it with everyone for your reference. The details are as follows:

 ?

1

2

3

4

5

6

7

8

9

10

11

12

$name = 'Simon'; //对变量$name进行赋值(传值赋值)

$name_b = $name; //对变量$name_b进行赋值(传值赋值)

$addr = &$name; //对变量$addr进行赋值(传地址赋值)

$name = "Elaine"; //改变$name的值

echo $name; //输出$name,会发现$name的值发生了变化

echo $name_b; //输出$name_b,会发现$name_b的值没有发生变化

echo $addr; //输出$addr,会发现$addr的值发生了变化

$addr = "Helen"; //改变$addr的值

echo $name; //输出$name,会发现$name的值发生了变化

echo $addr; //输出$addr,会发现$addr的值发生了变化

?>

1

2 3

45 6 7 8 9 10
11
12
<🎜>$name = 'Simon'; //Assign a value to the variable $name (assignment by value)<🎜> <🎜>$name_b = $name; //Assign a value to variable $name_b (assignment by value)<🎜> <🎜>$addr = &$name; //Assign value to variable $addr (pass address assignment)<🎜> <🎜>$name = "Elaine"; //Change the value of $name<🎜> <🎜>echo $name; //Output $name, you will find that the value of $name has changed<🎜> <🎜>echo $name_b; //Output $name_b, you will find that the value of $name_b has not changed<🎜> <🎜>echo $addr; //Output $addr, you will find that the value of $addr has changed<🎜> <🎜>$addr = "Helen"; //Change the value of $addr<🎜> <🎜>echo $name; //Output $name, you will find that the value of $name has changed<🎜> <🎜>echo $addr; //Output $addr, you will find that the value of $addr has changed<🎜> <🎜>?>
I hope this article will be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/1020291.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1020291.htmlTechArticlePHP value assignment and address assignment usage example analysis This article explains the use of PHP value assignment and address assignment . Share it with everyone for your reference. The details are as follows: ? 1 2 3 4 5 6 7...
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