#38294 [Bgs]: Problem in Example 19-5. Object Assignment.
| From: | rejek at sdnet dot pl | Date: | Wed, 02 Aug 2006 14:20:47 +0000 |
| Subject: | #38294 [Bgs]: Problem in Example 19-5. Object Assignment. | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969373640@lists.php.net to get a copy of this message | ||
ID: 38294
User updated by: rejek at sdnet dot pl
-Summary: Doc example problem
Reported By: rejek at sdnet dot pl
Status: Bogus
Bug Type: Documentation problem
Operating System: Linux
PHP Version: Irrelevant
New Comment:
This problem is in Example 19-5. Object Assignment.
The result of code given in documentation is diferent then the shown
one.
So I still think, that is a documentation bug.
Please execude code given in Example 19-5.
As I've written in first message moving line:
$instance->var = '$assigned will have this value';
just after <?PHP tag make this code giving right anwer.
MR
MR
Previous Comments:
------------------------------------------------------------------------
[2006-08-02 13:36:42] colder@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Using $instance = null won't affect the object itself. $assigned still
holds a reference to the object, as objects are assigned by reference
in PHP5.
------------------------------------------------------------------------
[2006-08-02 13:10:28] rejek at sdnet dot pl
In online doc. at:
http://www.php.net/manual/en/language.oop5.basic.php
http://pl.php.net/manual/pl/language.oop5.basic.php
there is the same problem.
MR
------------------------------------------------------------------------
[2006-08-02 12:22:14] rejek at sdnet dot pl
Description:
------------
Look at the Ex. 19-4 in polish ver. of documentation avaible to
download at
http://pl2.php.net/get/php_manual_pl.html.gz/from/pl.php.net/mirror
The line "$instance->var = '$assigned will have this value';"
should be just after "<?PHP" tag to get the expected result given in
the box under ex. code.
I don't know how it looks in other language versions.
Brgs
Mateusz Rejek
Reproduce code:
---------------
<?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);
?>
Expected result:
----------------
NULL NULL object(stdClass)#1 (1) { ["var"]=> string(30) "$assigned
will have this value" }
Actual result:
--------------
NULL NULL NULL
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38294&edit=1