get classname without namespace
| From: | Tanel Tammik | Date: | Sat, 29 May 2010 20:20:31 +0000 |
| Subject: | get classname without namespace | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-305640@lists.php.net to get a copy of this message | ||
Hi,
is there a way to get the called classname without the namespace?
<?php
//PHP 5.3.x
namespace some\where;
abstract class ParentClass {
public static function name() {
return strtolower(get_called_class());
}
public static function get_name() {
echo 'name: ' . static::name();
}
}
class ChildClass extends ParentClass {
}
ChildClass::get_name();
?>
the result i need: childclass
the result i get: some\where\childclass
also is it possible to get the name() into the static variable if only
static method is called?
Br
Tanel