diff --git a/language/references.xml b/language/references.xml index 0e18f190a4..9cd21d9080 100644 --- a/language/references.xml +++ b/language/references.xml @@ -1,5 +1,5 @@ - + References Explained @@ -117,6 +117,32 @@ echo "var2 is set to '$var2'\n"; // var2 is set to 'Example variable' to $var only changes the local variable's reference. + + + Complex arrays are sometimes rather copied than referenced. Thus following + example will not work as expected. + + References with complex arrays + + array(), + 'B' => array( + 'B_b' => array(), + ), +); + +$top['A']['parent'] = &$top; +$top['B']['parent'] = &$top; +$top['B']['B_b']['data'] = 'test'; +print_r($top['A']['parent']['B']['B_b']); // array() +?> +]]> + + + + The second thing references do is to pass variables by-reference. This is done by making a local variable in a function and