Re: getting classname of current class
| From: | Marek Kilimajer | Date: | Fri, 06 Feb 2004 15:39:19 +0000 |
| Subject: | Re: getting classname of current class | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177018@lists.php.net to get a copy of this message | ||
Not an answer to your question, but you should not use function names beginning with 2 underscores (__arr in your case) unless you want to use special functionality associated with that name (e.g. __construct). This will avoid possible conflicts with future version of php.
Vivian Steller wrote:
Hi, i've just another problem concerning classes, inheritance and the '::' Syntax. Take a look at the following example code: <pre> <?phpclass MyClass extends MyParent{ private $__arr = Array();public function __construct() { $this->__arr("test"); } public function __arr($var) { array_push($this->__arr, $var); } } class MyParent { public function getClassname() { print("My classname: " . __class__ . "\n"); print("My classname: " . get_class($this) . "\n"); } } $obj = new MyClass(); // print_r($obj); MyClass::getClassname();?> </pre> Corresponding output:My classname: MyParent My classname:The problem is, that i want MyClass::getClassname() to return "MyClass"?! Can anybody help me? Thanks a lot. vivi