Static and Non-Static Calling in PHP
oop, php
Solution
Here is the rule:
A static method can be used in both static method and non-static method.
A non-static method can only be used in a non-static method.
Problem
ok I have this code, that I'm studying ``` class scope{ function printme(){ return "hello"; } public static function printme(){ return "hello"; } } $s = new scope(); echo $s->printme(); //non-static call echo "<br>"; echo scope::printme(); //static call ``` Now, this is not really the code of my project but these are the things I want to do - I want to create a class the will contain static and non-static functions. - I want a function to be available both on static and non-static calls. As non-static function has a lot of operations on it, I also need to call it as a static function so that I will not need to instantiate the class. Is this possible? or I really needed to rewrite the function to another function or class? NOTE: tell me if I'm doing some bad programming already.