Re: How to get the child name from within the parent?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Robert.Degen@xxxxxxxxxxxxxx wrote:
----- Ursprüngliche Nachricht -----
Von: Mathijs <mathijs.van.veluw@xxxxxxxxxxx>
Datum: Montag, September 10, 2007 3:19 pm
Betreff:  How to get the child name from within the parent?
An: php-general@xxxxxxxxxxxxx

Hello there,

Is there a way to get the child class name from within the parent method?

Yes.

If so, how?

1) If you abandon static'ness, you can use 'get_class($this)' within parent class' func.
2) Fizzle around with some 'self' as pass over argument.
3) or else.....

But - I can't recognize any exigence. Could you describe *what* you wanna do so you must use this?


I need this because i want to make a default Flow-Control class.
Other classes can extend from this flow class, and pass an array with the kind of flow they want.

Some of these methods are in the child-class and there for i need its name.

But i didn't checked non-static part yet.
Going to try this.

Thx.


Thx in advance.

Example:

class MyParent {
 public static function start() {
  // Do something like this???

  return get_child_name(); // returns 'MyChild' in this case

I don't know this function. I couldn't even find it at php doc.
WHAT is that ?

 }
}

class MyChild extends MyParent {

 public static childStart() {

public static function childStart() {

Oeps, forgot that.

  // Should return the child class name.
  echo parent::start();
 }
}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


So far.

Rob

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux