Re: Extending a class with a static constructur (like PEAR::DB)
| From: | Chris | Date: | Thu, 09 Mar 2006 23:43:02 +0000 |
| Subject: | Re: Extending a class with a static constructur (like PEAR::DB) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-231741@lists.php.net to get a copy of this message | ||
weston@leary.csoft.net wrote:
So... I'm trying to extend PEAR::DB. It'd be great to keep everything it offers and just add a few more perhaps unconventional functions. Intuitively, it seemed like this approach might work: <?PHP$dte will only have the return value of DBToyExt::connect() - it won't allow you to access other methods in the class. You'll need to: $dbtoy = new DBToyExt(); $dbtoy->connect(....) $dbtoy->testext('testing'); -- Postgresql & php tutorials http://www.designmagick.com/require_once("DB.php");# Toy Extension of DB Classclass DBToyExt extends DB { var $foo = 1; var $bar = 2;function testext($x) { echo "\nHEY: $x"; } }$dte = DBToyExt::connect("mysql://weston_tssa:******@localhost/weston_tssa");$dte->testext('testing'); $dte->testext($dte->moo); $dte->testext($dte->bar);?> However, it doesn't seem to understand that the method "testext" exists, and gives me a fatal error to that effect, as you can see: