PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
First one is a static call on whatever type of object $this is (as opposed to a static call using the actual name of the class). Since it's $this you should use self instead.
thanks for the reply requinix, does this mean I use :: only when referring to any static functions or members only? what's the side effect if I use :: to call instance member and functions?
global_erp_solution wrote:does this mean I use :: only when referring to any static functions or members only?
Yes.
global_erp_solution wrote:what's the side effect if I use :: to call instance member and functions?
Method: It's called statically (no $this) and you get a Strict "Non-static method Class::method() should not be called statically".
Variable: PHP will look for a static member variable, not find it, and crash with a Fatal "Access to undeclared static property Class::$variable".