LonghornPHP 2026

Voting

: eight minus five?
(Example: nine)

The Note You're Voting On

rahul dot anand77 at gmail dot com
10 years ago
To check if a method declared in a class is static or not, you can us following code. PHP5 has a Reflection Class, which is very helpful. 

try {
    $method = new ReflectionMethod( 'className::methodName );
    if ( $method->isStatic() )
    {
        // Method is static.
    }
}
catch ( ReflectionException $e )
{
    //    method does not exist
    echo $e->getMessage();
}

*You can read more about Reflection class on http://php.net/manual/en/class.reflectionclass.php

<< Back to user notes page

To Top