Note Submitter: code dot zhili at gmail dot com
----
To hugo (@) apres (dot) net
Your code is really great, very useful.
This is a great example to extends the core functions of php OOP features.
<?php
class Multiple_inheritance {
public $bases = array();
static function error_die($errno, $errstr, $errfile, $errline) {
$backtrace = debug_backtrace();
$detail = $backtrace[4];
var_dump( $backtrace );
echo '<b>Fetal Error</b>: '.$errstr.' of class <b>'.$detail['class'].'</b> in <b>'.$detail['file'].'</b> on line <b>'.$detail['line'].'</b><br/>';
die();
}
private function fatal( $text ) {
set_error_handler( array( 'inheritance', 'error_die' ) );
trigger_error( $text, E_USER_ERROR );
restore_error_handler();
}
function __call( $name, $args ) {
if( $this-> bases )
foreach( $this->bases as $base )
if( method_exists( $base, $name ) )
return $base->$name( $args );
$this->fatal( "Call to undefined method <b>".$name."</b>" );
}
function __set( $name, $value ) {
if( $this->bases ) {
foreach( $this->bases as $base ) {
if( property_exists( $base, $name )) {
$base->$name = $value;
return;
}
}
}
}
function __get( $name ) {
if( $this->bases ) {
foreach( $this->bases as $base ) {
if( property_exists( $base, $name ) ) {
return $base->$name;
}
}
}
}
function __isset( $name ) {
if( $this->bases ) {
foreach( $this->bases as $base ) {
if( property_exists( $base, $name ) ) {
return isset( $base->$name );
}
}
}
}
function __unset( $name ) {
if( $this->bases ) {
foreach( $this->bases as $base ) {
if( property_exists( $base, $name) ) {
unset( $base->$name );
}
}
}
}
function inherits( $name, $args = '' ) {
return array_unshift( $this->bases, new $name( $args ) );
}
}
?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.