Closed imarshmultani closed 9 years ago
When you call a method statically you can't use $this
as there's no object context. You'll need to instantiate User
first. Not sure if you meant to define the function statically or not.
$userObj = new User;
echo $userObj->router_called_function();
but as i have described the problem , is it possible to avoid static ? and use normal public function or i have too call the class again n again inside functions to connect with other functions ? inside the same class?
i have an User class which contains too many functions, not all are being called from the router , most of them are to save data , get data , filtering and much more which i need to use inside my function called : facebook_login which is connected to router for executing the facebook login and then when the action is triggered from the url i also need to connect with facebook's api class by extending it or calling it inside : __construct function ,, but that always not let me do that.
You can avoid using static if you instantiate an object of the class and then call the function from that object.
suppose i have the following code :
so as per the code when action 'router_called_function' is called i have to access the object : $myvar or $this->myvar but it does not let me use it , it says :
Fatal error: Using $this when not in object context in