PHP - forward_static_call()
The forward_static_call() function can call a static method.
Syntax
mixed forward_static_call( callable $function [, mixed $parameter [, mixed $... ]] )
The forward_static_call() function can call a user-defined function or method given by the function parameter. It must be called within a method context and can't be used outside a class. It can use the late static binding.
Example
<?php
class Beer {
const NAME = 'Beer!';
public static function printed(){
echo 'static Beer:NAME = '. static::NAME . "\n";
}
}
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 "\n";
?>
Output
static Beer:NAME = Ale! static Beer:NAME = Ale! static Beer:NAME = Ale! static Beer:NAME = Beer!
php_function_reference.htm
Advertisements