diff --git a/language/operators.xml b/language/operators.xml index c90bdad192..eb95605420 100644 --- a/language/operators.xml +++ b/language/operators.xml @@ -364,17 +364,75 @@ $b .= "There!"; // sets $b to "Hello There!", just like $b = $b . "There!"; Note that the assignment copies the original variable to the new one (assignment by value), so changes to one will not affect the other. This may also have relevance if you need to copy something - like a large array inside a tight loop. Assignment - by reference is also supported, using the $var = - &$othervar; syntax. - 'Assignment by reference' means that both variables end - up pointing at the same data, and nothing is copied anywhere. - To learn more about references, please read References explained. As of - PHP 5, objects are assigned by reference unless explicitly told - otherwise with the new clone - keyword. + like a large array inside a tight loop. + + An exception to the usual assignment by value behaviour within PHP occurs + with objects, which are assigned by reference in PHP 5. + Objects may be explicitly copied via the clone keyword. + + + + Assignment by Reference + + Assignment by reference is also supported, using the + "$var = &$othervar;" syntax. + Assignment by reference means that both variables end up pointing at the + same data, and nothing is copied anywhere. + + + + Assigning by reference + + +]]> + + + + + As of PHP 5, the new + operator returns a reference automatically, so assigning the result of + new by reference results + in an E_DEPRECATED message in PHP 5.3 and later, and + an E_STRICT message in earlier versions. + + + For example, this code will result in a warning: + + + +]]> + + + + + More information on references and their potential uses can be found in + the References Explained + section of the manual. + + diff --git a/language/references.xml b/language/references.xml index 6d5290c710..0f5fb3a1e1 100644 --- a/language/references.xml +++ b/language/references.xml @@ -105,7 +105,8 @@ $foo =& find_var($bar); Since PHP 5, new returns a reference automatically, so using =& in this context is deprecated and - produces an E_STRICT message. + produces an E_DEPRECATED message in PHP 5.3 and + later, and an E_STRICT message in earlier versions.