#44467 [Opn->Asn]: wrong oop example in provided manual of php installer package

From: Date: Sun, 13 Apr 2008 23:54:41 +0000
Subject: #44467 [Opn->Asn]: wrong oop example in provided manual of php installer package
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-701@lists.php.net to get a copy of this message
ID: 44467 Updated by: bjori@php.net Reported By: krille at thomaskrille dot de -Status: Open +Status: Assigned Bug Type: Documentation problem Operating System: windows XP PHP Version: Irrelevant -Assigned To: +Assigned To: rquadling Previous Comments: ------------------------------------------------------------------------ [2008-03-19 12:51:40] rquadling@php.net Maybe this is a better example. <?php class SimpleClass{} $instance = new SimpleClass(); $assigned = $instance; $reference =& $instance; $instance->var = '$assigned will have this value'; var_dump($instance->var); var_dump($reference->var); var_dump($assigned->var); $instance = null; // $instance and $reference become null var_dump($instance->var); var_dump($reference->var); var_dump($assigned->var); ?> In PHP5 the output is ... string(30) "$assigned will have this value" string(30) "$assigned will have this value" string(30) "$assigned will have this value" NULL NULL string(30) "$assigned will have this value" In PHP4 the output is ... string(30) "$assigned will have this value" string(30) "$assigned will have this value" NULL NULL NULL NULL ------------------------------------------------------------------------ [2008-03-18 11:05:19] krille at thomaskrille dot de Description: ------------ in the provided (.chm) manual of the php installer package the following example is given in Lang.Ref.->Classes and ...(PHP5)->The Basics: <?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); ?> The above example will output: NULL NULL object(SimpleClass)#1 (1) { ["var"]=> string(30) "$assigned will have this value" } this example describes the php4 behavior, not the php5 one. i haven't checked if this mistake is also exsists in other provided manuals. manual version: "Sun Nov 11 00:33:08 2007" Reproduce code: --------------- n/a Expected result: ---------------- n/a Actual result: -------------- n/a ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44467&edit=1

« previous php.doc.bugs (#701) next »