Suppose I want to have two variables and have them both equal to null
. (More realistically, I am thinking about an array that contains a large amount of null
s, but the "two variables" scenario is sufficient for the question.) Obviously, I can do this in more than one way. I can do this (method 1):
$a = null;
$b = $a;
By my understanding, the result of this is that there is one zval that is pointed to by two entries in the symbol table: 'a'
and 'b'
. But alternatively one might do this (method 2):
$a = null;
$b = null;
Naively one would expect that this should result in two different zvals, each pointed to by one entry in the symbol table.
Does it follow from this that if you want to have a large array, and many elements of the array will be null
, it's more efficient (in terms of zval/memory use) to create a $master_null
variable with the value null
, and then write the null
elements of the array by assigning using $master_null
?