ID: 38294
User updated by: rejek at sdnet dot pl
Reported By: rejek at sdnet dot pl
-Status: Open
+Status: Closed
Bug Type: Documentation problem
Operating System: Linux
PHP Version: Irrelevant
New Comment:
Running script containing above code gives proper result.
Problem is my misunderstanding of the example.
I'm closing the issue, but I suggest to change the way of giving
examples.
Previous Comments:
------------------------------------------------------------------------
[2006-08-02 14:36:15] RQuadling at GMail dot com
If the example was ...
[code]
<?php
class SimpleClass
{
// member declaration
public $var = 'a default value';
// method declaration
public function displayVar() {
echo $this->var;
}
}
$instance = new SimpleClass();
$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);
?>
[/code]
Then that would be more meaningfull. The documented example assumes
that you are using the simple class and that you have created an
instance of it. Without that the output is just junk.
E.g.
C:\>php
<?php
class SimpleClass
{
// member declaration
public $var = 'a default value';
// method declaration
public function displayVar() {
echo $this->var;
}
}
$instance = new SimpleClass();
$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);
?>
^Z
NULL
NULL
object(SimpleClass)#1 (1) {
["var"]=>
string(30) "$assigned will have this value"
}
C:\>
------------------------------------------------------------------------
[2006-08-02 14:33:36] rejek at sdnet dot pl
still open
------------------------------------------------------------------------
[2006-08-02 14:20:45] rejek at sdnet dot pl
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
------------------------------------------------------------------------
[2006-08-02 13:36:42] [EMAIL PROTECTED]
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
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/38294
--
Edit this bug report at http://bugs.php.net/?id=38294&edit=1