View Single Post
Old 03-19-2008, 10:13 PM   #8 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by xenon View Post
Question: what the hell are you talking about?



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.
Ahh yes the static, otherwise I don't get you. Visiblity, what about it? I understand public, private, protected.
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote