How do I call a static child function from parent static function?

If you are referring to a static parent function, then you need to explicitly name the parent (or child) for the function call in php 5.1: parentClass::func(); Test123456::test() In PHP 5.3 you can do this instead with the static keyword PHP Manual to resolve the called class' name: static::func(); static::test() If those are non-static, just use $this PHP Manual : $this->parentFunc(); $this->childFunc() Or if it has the same name, use parent PHP Manual : parent::parentFunc() (which is not exactly what you asked for, just putting it here for completeness) Get_called_class() has been introduced for very specific cases like to late static bindings PHP Manual See Object Inheritance PHP Manual.

If you are referring to a static parent function, then you need to explicitly name the parent (or child) for the function call in php 5.1: parentClass::func(); Test123456::test(); In PHP 5.3 you can do this instead with the static keyword PHP Manual to resolve the called class' name: static::func(); static::test(); If those are non-static, just use $this PHP Manual: $this->parentFunc(); $this->childFunc(); Or if it has the same name, use parent PHP Manual: parent::parentFunc(); (which is not exactly what you asked for, just putting it here for completeness). Get_called_class() has been introduced for very specific cases like to late static bindings PHP Manual. See Object Inheritance PHP Manual.

– phant0m Jul 13 at 12:14 :( I'm a bit disappointed now, hehe - thanks, anyway. – phant0m Jul 13 at 12:17.

I suspect you are a bit confused abuot parent / child, class / object and function / method. IonuÈ› G. Stan has provided the explanation of how to invoke a method which is not declared in a parent class (which as he says should be abstract or implement the __call() method).

However if you mean how do invoke a method which has been overridden in a child class from the parent, then it is not possible - nor should it be. Consider: Class shape { ... } Class circle extends shape { function area() { } } Class square extends shape { function area() { } } If it is your intent to call the area method on an instance of 'shape' (which does not have an area method) then which child should it use? Both the child methods would depend on properties which are not common / not implemented by the shape class.

In php5.3 there is a built in method called get_called_class() to call child method from parent class. Is there any way can do this? I want to call it from a static function .

So I should use "self" keyword.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions