"php isset($this) and using the same object method in a static and object context" Code Answer

4

the issue with the second method is that it will result in an error when error reporting is set to e_strict. for example:

strict standards: non-static method foo::bar() should not be called statically in /home/yacoby/dev/php/test.php on line 10

a point with php6 is that the e_strict errors are moved to e_all. in other words e_all will cover all errors including not allowing you to call non static methods statically.

an alternative method may be to move the validation logic to a static function. that way the non static function and the static function can call the validation logic.

By PatL on August 18 2022

Answers related to “php isset($this) and using the same object method in a static and object context”

Only authorized users can answer the Search term. Please sign in first, or register a free account.