2 ms·
>I would call the first two pointers (to [1,2] and [3,4]), and the latter two references (to $first and $second). What would you call them? In the first case,
by coldtea 10y ago
>I would call the first two pointers (to [1,2] and [3,4]), and the latter two references (to $first and $second). What would you call them?
In the first case, $a and $b pass the arrays by copying their values. The second example uses references.
Java can't do the change visible externally because it passes its references by value -- but that's not a necessity for all languages with references.
As the PHP manual itself says: "References in PHP are a means to access the same variable content by different names. They are not like C pointers; for instance, you cannot perform pointer arithmetic using them, they are not actual memory addresses, and so on".