- var_dump: documentation ( source)
<?php
class Foo {
public $prop;
function setStr(string $x) {
$this->prop = $x;
}
function setStrRef(string &$x) {
$this->prop = &$x;
}
function setArray(array $arr) {
$this->prop = $arr;
}
}
$foo = new Foo();
$foo->setStr('abc');
var_dump($foo->prop); // "abc"
$str = 'def'; // $str is a string
$foo->setStrRef($str);
var_dump($foo->prop); // "def"
$arr = [];
$foo->setArray($arr);
var_dump($foo->prop); // []
var_dump($str); // [] - surprise! $str is now an array