note 37726 rejected from keyword.extends by lynch
| From: | lynch@php.net | Date: | Tue, 11 Apr 2006 23:53:06 +0000 |
| Subject: | note 37726 rejected from keyword.extends by lynch | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-107823@lists.php.net to get a copy of this message | ||
Note Submitter: zombie(at)artattack(dot)to
----
Typically you want to keep your scripts short and modular by including libraries of functions.
However this does not work when defining classes.
The below code doesn't work
----------------------------------------------------
//a.php
class A{
function derp(){
return 'OI';
}
include_once('alib.php');
}
echo '<strong>testing...</strong><br /><br />';
$o = new A();
echo $o->derp() . '<BR />';
echo $o->bork() . '<BR />';
----------------------------------------
//alib.php
function bork(){
return 'captain planet';
}
----------------------------------------
The include cannot be in the class def. If you
include with a method, the functions are in
the scope of the script and not class methods.
If this were to work, it would be a nifty hack to organize code, especially if you are working in a
modular system. It might also be a very hacked way for multiple inheritance.
Blaine Flynn Garrett
http://artattack.to?zombie