Search
 
SCRIPT & CODE EXAMPLE
 

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');
Comment

PREVIOUS NEXT
Code Example
Php :: php rand between 0 and 1 
Php :: php fpdf in phpmailer 
Php :: $faker-paragraph 
Php :: php is_assoc 
Php :: laravel form request validation api 
Php :: php return more than one value 
Php :: Create progress bar with Laravel 
Php :: php preplace 
Php :: login with email or username codeigniter 4 
Php :: octobercms mail 
Php :: Define memory limit in PHP 
Php :: guzzlehttp http_errors get 
Php :: eloquent search ignore case 
Php :: php remove html tag wrap 
Php :: laravel route group 
Php :: check if the logged in user is admin 
Php :: php file hash 
Php :: clear log file laravel 
Php :: submit form and show results on same page without refresh 
Php :: wp wordPress variables de session 
Php :: parse php 
Php :: parseint php 
Php :: pessimistic locking laravel 
Php :: laravel where json array column 
Php :: strcmp php 
Php :: adding two numbers in php 
Php :: how to run php on windows 
Php :: API call in PHP using cURL 
Php :: sass for php 
Php :: Laravel render stuff in a given environment 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =