about php manual Classes and Objects (PHP 5) Example#5 Object Assignment
| From: | tatsuki monji | Date: | Mon, 12 Jul 2010 07:32:53 +0000 |
| Subject: | about php manual Classes and Objects (PHP 5) Example#5 Object Assignment | ||
| Groups: | php.doc.license | ||
| Request: | Send a blank email to doc-license+get-271@lists.php.net to get a copy of this message | ||
hello.
i'm monji.
i'm really grateful to your php manual.
it helps me to study php.
today i think i found the mistake in Classes and Objects (PHP 5) Example#5
Object Assignment.
example is
<?php
$assigned = $instance;
$reference =& $instance;
$instance->var = '$assigned will have this value';
$instance = null; // $instance and $reference become null
var_dump($instance);
var_dump($reference);
var_dump($assigned);
?>
and it say
The above example will output:
NULL
NULL
object(SimpleClass)#1 (1) {
["var"]=>
string(30) "$assigned will have this value"
}
but it output
NULL
NULL
NULL
i think example should be like this
<?php
$instance->var = '$assigned will have this value';
$assigned = $instance;
$reference =& $instance;
$instance = null; // $instance and $reference become null
var_dump($instance);
var_dump($reference);
var_dump($assigned);
?>
please check that.
i'm sorry for my poor english.