php access non static function

Solutions on MaxInterview for php access non static function by the best coders in the world

showing results for - "php access non static function"
Valentino
13 Aug 2018
1class Foo {
2
3    private $foo;
4    private $bar;
5
6    public function __construct($foo, $bar)
7    {
8        $this->foo = $foo;
9        $this->bar = $bar;
10    }
11
12    public function fun1()
13    {
14        return $this->foo . ' - ' . $this->bar;
15    }
16
17    public static function fun2($foo, $bar)
18    {
19        return (new self($foo, $bar))->fun1();
20    }
21}
22
23echo Foo::fun2('foo', 'bar');
24
Lili-Rose
01 Oct 2018
1<?php
2	class Toys
3	{
4		private $toys_name;
5		public $toys_category;
6		public static $shop_name;
7
8		function Toys($name,$category) 
9		{
10			$this->toys_name = $name;
11			$this->toys_category = $category;
12		}
13
14		public function getToyName() 
15		{ 
16			return $this->toys_name; 
17		}
18
19		public function getToyCategory() 
20		{ 
21			return $this->toys_category; 
22		}	
23
24		public function getToyShop_nonStatic() 
25		{ 
26			return self::getToyShop(); 
27		}
28
29		public static function getToyShop() 
30		{ 
31			return self::$shop_name;
32		}
33
34		public static function setToyShop($shopname) 
35		{ 
36			self::$shop_name=$shopname; 
37		}
38
39	}
40
41	$objToys = new Toys("Battery Car","Battery Toys");
42	$toys_name = $objToys->getToyName();
43	$toys_category = $objToys->getToyCategory();
44	echo "<br/>Toy: " . $toys_name . ", Category: " . $toys_category;
45
46	Toys::$shop_name = "Disney";
47	$shop_name = Toys::getToyShop();
48	echo "<br/>Shop Name: " . $shop_name;
49
50	Toys::setToyShop("ToyShop");
51	$shopname = Toys::getToyShop_nonStatic();
52	echo "<br/>Shop Name via non static function: " . $shopname;
53
54?>
queries leading to this page
non static function phphow to call non static method phpphp have a static and non static method with the same namenon static method inside static method phpphp call non static method inside it 27s own classwhy would you want to use a static method over a non static phphow to call a non static method as a static method phpphp call non static method inside staticreference a non static function phphow to call a non static method in a static function in phphow to make function non static in php 24this static function phphow to call non static method from static method in phphow to call non static function in static function of php classphp use static functionphp call non static method from static methodhow to call a non static function from a non static function in phpnon static method phpphp getstatic function by namephp calling methods statical 3blyphp access non static function in static functionphp call non static method staticallyphp call static method as non staticphp call non static methodaccess static properties inside static methods phpcall non static method inside static method phpnon static phpcall non static method in static method phphow to use static function to call non static function phpphp static function calling a non static functionstatic function phpcall non static method phphow to call non static method from static method of different class phpcall static method from non static method phpaccess non static method from static phpphp static methodsphp method for call non static methodsphp access non static functionwhat is non static method in phpphp mock static methodhow to use non static variable in static method phpuse non static variable in static method phpcall class non static methods in static function phpcall non static method statically phpnon static method from static phpcan we call static method from non static method phget static function phpphp calling methods staticallyphp static vs non static functionphp cannot make non static methodget property in static function phphow to call non static method php classphp how to call a non static method inside a static methodphp static and non static functionsnon static function in phpaccess non static method from static method phpcall non static method from static method phpphp call function by name non staticcall a non static method from a static method phpwhy avoid static methods phpstatic method phprun non static method in static method phpstatic function call non static function phpnon static method inside static method phpcall a non static method from a static method in php laravelphp static methodaccess non static variable from static method phpphp call static function within classadd property in staic method oop phpnon static method in a static method in phpphp how to call non static method from static methodcall non static function from static function phpphp error 3a non static methodphp call non static method from stringhow to call non static method in another class in phphow to call non static method inside static method in phpphp call a no static function from a static methodphp access non static function