Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php call non static method from static method

class Foo {

    private $foo;
    private $bar;

    public function __construct($foo, $bar)
    {
        $this->foo = $foo;
        $this->bar = $bar;
    }

    public function fun1()
    {
        return $this->foo . ' - ' . $this->bar;
    }

    public static function fun2($foo, $bar)
    {
        return (new self($foo, $bar))->fun1();
    }
}

echo Foo::fun2('foo', 'bar');
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #call #static #method #static #method
ADD COMMENT
Topic
Name
9+1 =