note 98931 deleted from function.forward-static-call-array by danbrown

From: Date: Fri, 16 Jul 2010 13:07:48 +0000
Subject: note 98931 deleted from function.forward-static-call-array by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-170905@lists.php.net to get a copy of this message
Note Submitter: stefan(dot)krenz(at)mdcc-fun(dot)de ---- call_user_func_array() and forward_static_call_array() doesn't give the same result. In reference to the example: call_user_func_array(array('A', 'test'), array('more', 'args')) calls the static function 'test()' in class 'A' (like A::test('more', 'args')). But forward_static_call_array(array('A', 'test'), array('more', 'args')) calls 'test()' from class 'A' as a method of class 'B'. An example for better understandig: <?php class A { const NAME = 'A'; public static function test() { $args = func_get_args(); echo static::NAME, " ".join(',', $args)." \n"; } } class B extends A { const NAME = 'B'; public static function test() { echo self::NAME, "\n"; call_user_func_array(array('A', 'test'), array('more', 'args')); forward_static_call_array(array('A', 'test'), array('more', 'args')); } } B::test('foo'); ?> Output: B A more,args B more,args Greetz Stefan

« previous php.notes (#170905) next »