Re: get classname without namespace

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

 



On 05/29/2010 03:20 PM, Tanel Tammik wrote:
> 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

I would use basename()

> also is it possible to get the name() into the static variable if only 
> static method is called?

???

> Br
> Tanel 
> 
> 


-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
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