당신은 또한 심지어 클래스를 인스턴스화하지 않고, 특정 방법의 존재를 확인할 수 있습니다
echo method_exists(bob, 'yippie') ? 'yes' : 'no';
당신이 Reflection API (만 PHP5)를 사용하여, 한 걸음 더 나아가 "이피은"실제로 고정되어 있는지 확인하려면
try {
$method = new ReflectionMethod('bob::yippie');
if ($method->isStatic())
{
// verified that bob::yippie is defined AND static, proceed
}
}
catch (ReflectionException $e)
{
// method does not exist
echo $e->getMessage();
}
또는, 당신은 두 가지 방법을 결합 할 수
if (method_exists(bob, 'yippie'))
{
$method = new ReflectionMethod('bob::yippie');
if ($method->isStatic())
{
// verified that bob::yippie is defined AND static, proceed
}
}