Home  >  Article  >  Backend Development  >  赋值操作符_PHP

赋值操作符_PHP

WBOY
WBOYOriginal
2016-06-01 12:39:53805browse

基本的赋值操作符就是“=”。您往往会倾向于认为它的含义就是“等于”。不要这样想,它真正的含义就是左侧的操作数获得右侧表达式的值。

一个赋值表达式的意义在于值的指派。也就是说,“$a=3”的值是3。这就允许您做这样的事情:

 

$a = ($b = 4) + 5;

// $a is equal to 9 now, and $b has been set to 4.

 

作为赋值操作符的一个补充,还有一个针对二进制数和字符传进行操作的组合操作符,该操作符允许您在赋值方采用被赋值表达式的值。例如:

 

$a = 3;

$a += 5; // sets $a to 8, as if we had said: $a = $a + 5;

$b = "Hello ";

$b .= "There!"; // sets $b to "Hello There!", just like $b = $b . "There!";






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:字符串操作符_PHPNext article:PHP3之FastTemplate_PHP