Re: pain

From: Date: Wed, 10 Sep 2008 22:39:05 +0000
Subject: Re: pain
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-279827@lists.php.net to get a copy of this message
Nathan Rixham schreef:
Not sure why I'm sharing this; but it could be a gotcha
been there, got the T-shirt, see below for my work around.
class testOuter {
    private $base;
        public function __construct()
    {
        $this->base = new testBase;
    }
    public function __call( $methodName , $values )
    {
        echo __METHOD__ . PHP_EOL;
        print_r( $values );
        $this->base->test( $values );
$this->base->__call( $methodName, $values ); or call_user_func_array(array($this->base, 'test'), $values); I prefer the first one because AFAIK it's faster, and it's easier to read :-)
    }
} $test = new testOuter; $test->test( 'test' ); ?> output: testOuter::__call Array (
    [0] => test
) testBase::__call Array (
    [0] => Array
        (
            [0] => test
        )
) point: note the $values keep getting nested into an array one deeper; get's frustrating when dealing with passing arrays and detecting whats in them! [consider if( count($values) ) or even foreach etc..]!


« previous php.general (#279827) next »