[英]What does a variable set to “&NULL” means in PHP?
I'm working on a tree structure in PHP. 我正在使用PHP的树结构。 When looping through the nodes, an exception is sometime thrown because some node that should not be null is null, more precisely it's set to "&NULL": 循环遍历节点时,会抛出异常,因为某些不应为null的节点为null,更确切地说,它设置为“&NULL”:
array(13) {
// ...
// some data...
// ...
["segments"]=>
NULL
["leaf"]=>
bool(false)
["children"]=>
&NULL
}
Since it's not inside quotes, I assume it's some kind of special value, but what does it mean? 由于它不在引号内,我认为它是某种特殊价值,但它是什么意思?
It just means that it is a reference to a value NULL
它只是意味着它是对NULL
值的引用
$a = array();
$n = null;
$a[1] =& $n;
var_dump($a); // array(1) { [1]=> &NULL }
If you change $n = null;
如果你改变$n = null;
to $n = 1;
到$n = 1;
- then you'll get &int(1)
- 然后你会得到&int(1)
It's a reference to a value that is null. 它是对null值的引用。 "&" is the reference symbol. “&”是参考符号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.