ReflectionFunction::__construct
ReflectionFunction オブジェクトを作成する
&reftitle.description;
public ReflectionFunction::__construct
Closurestringfunction
ReflectionFunction オブジェクトを作成します。
&reftitle.parameters;
function
調べたい関数あるいはクロージャの名前。
&reftitle.errors;
function パラメータが正しい関数名でない場合に
ReflectionException が発生します。
&reftitle.examples;
ReflectionFunction::__construct の例
The %s function '%s'\n".
" declared in %s\n".
" lines %d to %d\n",
$func->isInternal() ? 'internal' : 'user-defined',
$func->getName(),
$func->getFileName(),
$func->getStartLine(),
$func->getEndline()
);
// ドキュメントコメントを表示します
printf("---> Documentation:\n %s\n", var_export($func->getDocComment(), 1));
// static変数が存在すれば表示します
if ($statics = $func->getStaticVariables())
{
printf("---> Static variables: %s\n", var_export($statics, 1));
}
}
// ReflectionFunction クラスのインスタンスを作成します
dumpReflectionFunction(new ReflectionFunction('counter1'));
dumpReflectionFunction(new ReflectionFunction($counter2));
?>
]]>
&example.outputs.similar;
The user-defined function 'counter1'
declared in Z:\reflectcounter.php
lines 7 to 11
---> Documentation:
'/**
* 簡単なカウンタ
*
* @return int
*/'
---> Static variables: array (
'c' => 0,
)
===> The user-defined function '{closure}'
declared in Z:\reflectcounter.php
lines 18 to 23
---> Documentation:
'/**
* 別の簡単なカウンタ
*
* @return int
*/'
---> Static variables: array (
'd' => 0,
)
]]>
&reftitle.seealso;
ReflectionMethod::__construct
コンストラクタ