PHP 8.5.0 Released!

ReflectionFunctionAbstract::getStaticVariables

(PHP 5 >= 5.2.0, PHP 7, PHP 8)

ReflectionFunctionAbstract::getStaticVariablesstatic変数を取得する

説明

public ReflectionFunctionAbstract::getStaticVariables(): array

static変数を取得します。

パラメータ

この関数にはパラメータはありません。

戻り値

static変数の配列を返します。

参考

add a note

User Contributed Notes 1 note

up
5
Martiros Aghajanyan
11 years ago
<?php

function test()
{
    static $a = 0, $b = 15;
    $a++;
    $b++;
    return $a;
}

$rf = new ReflectionFunction('test');

// result - Array ( [a] => 0 [b] => 15 ) 
print_r( $rf->getStaticVariables() );

//call test function and print again static variables
test();

// result - Array ( [a] => 1 [b] => 16 ) 
print_r( $rf->getStaticVariables() );

?>
To Top