Как получить доступ к нестатическому методу\функции статического родительского класса через метод\функцию статического д ⇐ Php
Как получить доступ к нестатическому методу\функции статического родительского класса через метод\функцию статического д
When i call myFunc2() statically from child class it gives This is Child Class. only, not give with inherited with Hello! Manish. when i encounters it with mentioning parent::myFunc(); in child class it gives fatal error.
So please explain, How can i access myFunc1() function, through myFunc2() function from "OtherClass" child class?
my code is here:
when i put parent::myFunc(); like
class OtherClass extends MyClass { public static $name2 = 'Child Class.'; public static function myFunc2(){ **parent::myFunc();** echo "This is ".self::$name2." \n"; } } it gives fatal error:
Fatal error: Uncaught Error: Call to undefined method MyClass::myFunc() in E:\laragon\www\manish\static_class2.php:13 Stack trace: #0 E:\laragon\www\manish\static_class2.php(18): OtherClass::myFunc2() #1 {main} thrown in E:\laragon\www\manish\static_class2.php on line 13
Источник: https://stackoverflow.com/questions/780 ... ugh-static
When i call myFunc2() statically from child class it gives This is Child Class. only, not give with inherited with Hello! Manish. when i encounters it with mentioning parent::myFunc(); in child class it gives fatal error.
So please explain, How can i access myFunc1() function, through myFunc2() function from "OtherClass" child class?
my code is here:
when i put parent::myFunc(); like
class OtherClass extends MyClass { public static $name2 = 'Child Class.'; public static function myFunc2(){ **parent::myFunc();** echo "This is ".self::$name2." \n"; } } it gives fatal error:
Fatal error: Uncaught Error: Call to undefined method MyClass::myFunc() in E:\laragon\www\manish\static_class2.php:13 Stack trace: #0 E:\laragon\www\manish\static_class2.php(18): OtherClass::myFunc2() #1 {main} thrown in E:\laragon\www\manish\static_class2.php on line 13
Источник: https://stackoverflow.com/questions/780 ... ugh-static
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение