Home Menu

forward_static_call

Call a static method

Syntax

forward_static_call ( callable $function [, mixed $... ] ) : mixed

Parameters

function

The function or method to be called. This parameter may be an array, with the name of the class, and the method, or a string, with a function name.

...

Zero or more parameters to be passed to the function.

Return

Returns the function result, or FALSE on error.

Examples

<?

class A
{
    const NAME = 'A';

    public static function test() {
        $args = func_get_args();
        echo static::NAME . " " . self::NAME . " " . join(" ", $args) . "\n";
    }
}

class B extends A
{
    const NAME = 'B';

    public static function test() {
        $args = func_get_args();
        echo static::NAME . " " . self::NAME . " " . join(" ", $args) . "\n";
        forward_static_call(array('A', 'test'), 'more', 'args');
        forward_static_call('test', 'other', 'args');
    }
}

function test() {
    $args = func_get_args();
    echo "C " . join(" ", $args) . "\n";
}

B::test('some', 'args');

?>
B B some args
B A more args
C other args

PHP

JesusBible
HTMLCSSJSPHPSVGMore
AboutTerms