note 58437 deleted from language.oop5.static by cmb
| From: | cmb@php.net | Date: | Sun, 01 Sep 2019 07:30:11 +0000 |
| Subject: | note 58437 deleted from language.oop5.static by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212056@lists.php.net to get a copy of this message | ||
Note Submitter: Jakob Schwendner
----
Here is my solution to the static search method problem for data objects. I found the debug_trace
version posted earlier quite clever, but a little too risky.
<?php
class Foo {
static function find($class) {
$obj = new $class();
return $obj;
}
}
class Bar extends Foo {
static function find() {
return parent::find(__CLASS__);
}
function print_hello() {
echo("hello");
}
}
Bar::find()->print_hello();
?>