note 104861 modified in function.forward-static-call by danbrown

From: Date: Wed, 13 Jul 2011 17:08:54 +0000
Subject: note 104861 modified in function.forward-static-call by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181483@lists.php.net to get a copy of this message
Example to understand this function and difference with call_user_func: <?php class Beer { const NAME = 'Beer!'; public static function printed(){ echo 'static Beer:NAME = '. static::NAME . PHP_EOL; } } class Ale extends Beer { const NAME = 'Ale!'; public static function printed(){ forward_static_call(array('parent','printed')); call_user_func(array('parent','printed')); forward_static_call(array('Beer','printed')); call_user_func(array('Beer','printed')); } } Ale::printed(); echo '</pre>'; ?> --was-- Example to understand this function and difference with call_user_func: class Beer { const NAME = 'Beer!'; public static function printed(){ echo 'static Beer:NAME = '. static::NAME . PHP_EOL; } } class Ale extends Beer { const NAME = 'Ale!'; public static function printed(){ forward_static_call(array('parent','printed')); call_user_func(array('parent','printed')); forward_static_call(array('Beer','printed')); call_user_func(array('Beer','printed')); } } Ale::printed(); echo '</pre>'; http://php.net/manual/en/function.forward-static-call.php

« previous php.notes (#181483) next »