View Single Post
Old 03-19-2008, 10:04 PM   #7 (permalink)
xenon
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

Quote:
Originally Posted by Orc View Post
It grabs a method/member from a class, such as a member would be a variable, and a method would be a function. Its just encapsulation differences. :: is a double resolution or so as double colon, in hebrew it gives you an error ( 'Paarayadim Neuktodrim' ) something rather, so many are confused at that.
Question: what the hell are you talking about?

Quote:
Originally Posted by Orc View Post
Anyway, its just to grab a certain method/member from a class, thats it.
No, it's not. Check this out:

Code:
class Test
{
	protected $x = 2;
	
	public static function first_method()
	{
		return $this->x;
	}
	
	public static function second_method()
	{
		return 'cant use $this in static methods';
	}
	
	private static function third_method()
	{
		return 'you cant call me na na na na na';
	}
}

Test::first_method(); // Fatal error: Using $this when not in object context
Test::second_method(); // the right call
Test::third_method(); // Fatal error: Call to private method Test::third_method() from context ''
So you see, you can't just 'grab' any method/property from a class.

Tlc: it's pretty simple. Do you need an instance of a class to authenticate a user, for example? Then don't use static methods. Static methods are made for defining behavior, not functionality.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote