note 106741 deleted from function.get-class by danbrown
| From: | danbrown@php.net | Date: | Tue, 03 Jan 2012 22:21:10 +0000 |
| Subject: | note 106741 deleted from function.get-class by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-185349@lists.php.net to get a copy of this message | ||
Note Submitter: gwartur at gmail dot com
----
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