#50200 [Bgs]: get_class() is not the same as get_class($this)
| From: | sjoerd-php at linuxonly dot nl | Date: | Tue, 17 Nov 2009 10:00:59 +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-3199@lists.php.net to get a copy of this message | ||
ID: 50200
User updated by: sjoerd-php at linuxonly dot nl
Reported By: sjoerd-php at linuxonly dot nl
Status: Bogus
Bug Type: Documentation problem
PHP Version: Irrelevant
New Comment:
I thought the examples were informative instead of normative.
Previous Comments:
------------------------------------------------------------------------
[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