Are multiple variable assignments done by value or reference?

后端 未结 7 2137
天命终不由人
天命终不由人 2020-12-10 00:33
$a = $b = 0;

In the above code, are both $a and $b assigned the value of 0, or is $a just refer

7条回答
  •  执念已碎
    2020-12-10 00:54

    Regard this code as:

    $a = ($b = 0);
    

    The expression $b = 0 not only assigns 0 to $b, but it yields a result as well. That result is the right part of the assignment, or simply the value that $b got assigned to.

    So, $a gets assigned 0 as well.

提交回复
热议问题