<?php
$params = [1,2,3];
function transform(array &$params)
{
$references = [];
foreach ($params as &$value) {
$references[] = &$value;
}
$value = "foo";
return $references;
}
var_dump($params);
$p = transform($params);
var_dump($p);
debug_zval_dump($p);
debug_zval_dump($params);
- Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
array(3) {
[0]=>
&int(1)
[1]=>
&int(2)
[2]=>
&string(3) "foo"
}
array(3) refcount(2){
[0]=>
reference refcount(2) {
int(1)
}
[1]=>
reference refcount(2) {
int(2)
}
[2]=>
reference refcount(2) {
string(3) "foo" interned
}
}
array(3) refcount(2){
[0]=>
reference refcount(2) {
int(1)
}
[1]=>
reference refcount(2) {
int(2)
}
[2]=>
reference refcount(2) {
string(3) "foo" interned
}
}
- Output for 7.0.0 - 7.0.20, 7.1.0, 7.1.7 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
- array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
array(3) {
[0]=>
&int(1)
[1]=>
&int(2)
[2]=>
&string(3) "foo"
}
array(3) refcount(2){
[0]=>
&int(1)
[1]=>
&int(2)
[2]=>
&string(3) "foo" refcount(1)
}
array(3) refcount(2){
[0]=>
&int(1)
[1]=>
&int(2)
[2]=>
&string(3) "foo" refcount(1)
}
- Output for 7.1.5 - 7.1.6
- array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
array(3) {
[0]=>
&int(1)
[1]=>
&int(2)
[2]=>
&string(3) "foo"
}
array(3) refcount(2){
[0]=>
&int(1)
[1]=>
&int(2)
[2]=>
&string(3) "foo" refcount(2)
}
array(3) refcount(2){
[0]=>
&int(1)
[1]=>
&int(2)
[2]=>
&string(3) "foo" refcount(2)
}
- Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
- array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
array(3) {
[0]=>
&int(1)
[1]=>
&int(2)
[2]=>
&string(3) "foo"
}
array(3) refcount(2){
[0]=>
&long(1) refcount(2)
[1]=>
&long(2) refcount(2)
[2]=>
&string(3) "foo" refcount(2)
}
array(3) refcount(2){
[0]=>
&long(1) refcount(2)
[1]=>
&long(2) refcount(2)
[2]=>
&string(3) "foo" refcount(2)
}
preferences:
183.68 ms | 402 KiB | 226 Q