note 94504 added to language.oop5.paamayim-nekudotayim
| From: | wouter at interpotential dot com | Date: | Mon, 09 Nov 2009 15:24:52 +0000 |
| Subject: | note 94504 added to language.oop5.paamayim-nekudotayim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-162660@lists.php.net to get a copy of this message | ||
It's worth nothing, that the mentioned variable can also be an object instance. This appears to
be the easiest way to refer to a static function as high in the inheritance hierarchy as possible,
as seen from the instance. I've encountered some odd behavior while using static::something()
inside a non-static method.
See the following example code:
<?php
class FooClass {
public function testSelf() {
return self::t();
}
public function testThis() {
return $this::t();
}
public static function t() {
return 'FooClass';
}
function __toString() {
return 'FooClass';
}
}
class BarClass extends FooClass {
public static function t() {
return 'BarClass';
}
}
$obj = new BarClass();
print_r(Array(
$obj->testSelf(), $obj->testThis(),
));
?>
which outputs:
<pre>
Array
(
[0] => FooClass
[1] => BarClass
)
</pre>
As you can see, __toString has no effect on any of this. Just in case you were wondering if perhaps
this was the way it's done.
---
http://www.ilikealot.com/
http://www.interpotential.com/
----
Server IP: 69.147.83.197
Probable Submitter: 62.107.59.156
----
Manual Page -- http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php
Edit -- https://master.php.net/note/edit/94504
Del: integrated -- https://master.php.net/note/delete/94504/integrated
Del: useless -- https://master.php.net/note/delete/94504/useless
Del: bad code -- https://master.php.net/note/delete/94504/bad+code
Del: spam -- https://master.php.net/note/delete/94504/spam
Del: non-english -- https://master.php.net/note/delete/94504/non-english
Del: in docs -- https://master.php.net/note/delete/94504/in+docs
Del: other reasons-- https://master.php.net/note/delete/94504
Reject -- https://master.php.net/note/reject/94504
Search -- https://master.php.net/manage/user-notes.php