#50200 [Bgs]: get_class() is not the same as get_class($this)

From: Date: Tue, 17 Nov 2009 10:04:50 +0000
Subject: #50200 [Bgs]: get_class() is not the same as get_class($this)
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-3201@lists.php.net to get a copy of this message
ID: 50200 Updated by: rquadling@php.net Reported By: sjoerd-php at linuxonly dot nl Status: Bogus Bug Type: Documentation problem PHP Version: Irrelevant New Comment: The examples are part of the documentation. As they say, a picture paints a thousand words. Previous Comments: ------------------------------------------------------------------------ [2009-11-17 10:00:59] sjoerd-php at linuxonly dot nl I thought the examples were informative instead of normative. ------------------------------------------------------------------------ [2009-11-17 09:14:01] rquadling@php.net Example #2 Using get_class() in superclass clearly covers this. ------------------------------------------------------------------------ [2009-11-17 08:47:43] sjoerd-php at linuxonly dot nl Description: ------------ The documentation on get_class() does not specify what happens when the parameter is omitted. I assumed the parameter defaults to $this, but this is not the case. Note that this may also be a bug in the implementation instead of the documentation. Reproduce code: --------------- <?php class A { function a() { echo get_class(); echo get_class($this); } } class B extends A { } $b = new B(); $b->a(); ?> Actual result: -------------- get_class() in A will return A, where get_class($this) will return B. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50200&edit=1

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