[TOC]

第一种情况 方法

function foo() {
    echo "In foo()
\n"; } $func = 'foo'; $func(); // This calls foo()

第二种情况 对象

 class Foo
    {
        function Variable()
        {
            $name = 'Bar';
            $this->$name(); // This calls the Bar() method
        }
        function Bar()
        {
            echo "This is Bar";
        }
    }

第三种情况 静态方法

class Foo
{
    static $variable = 'static property';
    static function Variable()
    {
        echo 'Method Variable called';
    }
}
echo Foo::$variable; // This prints 'static property'. It does need a $variable in this scope.
$variable = "Variable";
Foo::$variable();  // This calls $foo->Variable() reading $variable in this scope.

`