note 106741 modified in function.get-class by danbrown
| From: | danbrown@php.net | Date: | Fri, 02 Dec 2011 22:21:50 +0000 |
| Subject: | note 106741 modified in function.get-class by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-184870@lists.php.net to get a copy of this message | ||
Get class name without namespace
This is the moust fast end more economy method
<?php
function get_class_name($object)
{
if (!is_object($object) && !is_string($object)) {
return false;
}
return trim(strrchr((is_string($object) ? $object : get_class($object)), '\\'),
'\\');
}
?>
Pay attention to, in this method not include explode - this is take many memory
function create at this conception (see below)
me at nwhiting dot com 06-Dec-2010 04:14
I fix one bug $object=null change to just $object
Good luck, and not use explode function everyway
--was--
Get class name without namespace
This is the moust fast end more economy method
function get_class_name($object)
{
if (!is_object($object) && !is_string($object)) {
return false;
}
return trim(strrchr((is_string($object) ? $object : get_class($object)), '\\'),
'\\');
}
Pay attention to, in this method not include explode - this is take many memory
function create at this conception (see below)
me at nwhiting dot com 06-Dec-2010 04:14
I fix one bug $object=null change to just $object
Good luck, and not use explode function everyway
http://php.net/manual/en/function.get-class.php