note 72661 deleted from keyword.extends by bjori
| From: | bjori@php.net | Date: | Tue, 24 Jul 2007 11:20:52 +0000 |
| Subject: | note 72661 deleted from keyword.extends by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-128879@lists.php.net to get a copy of this message | ||
Note Submitter: Mark Egli
----
A note to visus at portsonline dot net or anyone else trying to dynamically choose a parent class:
A much beter method than creating a second file is to use eval to create an intermediate class.
Compare the following to the solution from visus at portsonline dot net:
<?php
$databaseSystem = "mysql";
class mysql
{
function show()
{
print("bar");
}
}
eval('class intermediate extends ' . $databaseSystem . ' {}');
class ActiveRecord extends intermediate
{
function ActiveRecord()
{
print("foo");
}
}
$instance = new ActiveRecord;
$instance->show();
?>