@filpgame why not class_basename($objectOrString); ?
class_basename is over 10x slower on my machine anyway
using this script
$time = microtime(true); for($i=0; $i < 1000000; ++$i){ //$a=explode('\', CLASS); arraypop($a); // 0.29 sec substr(strrchr(CLASS, "\"), 1); // 0.15 sec //(new \ReflectionClass($this))->getShortName(); // 0.35 sec //classbasename(CLASS); // 3.6 sec } var_dump([ $time, microtime(true), (microtime(true)-$time), ]);
@filpgame
why not
class_basename($objectOrString); ?
class_basename is over 10x slower on my machine anyway
using this script
$time = microtime(true);
for($i=0; $i < 1000000; ++$i){
//$a=explode('\', CLASS); arraypop($a);
// 0.29 sec
substr(strrchr(CLASS, "\"), 1);
// 0.15 sec
//(new \ReflectionClass($this))->getShortName();
// 0.35 sec
//classbasename(CLASS);
// 3.6 sec
}
var_dump([
$time,
microtime(true),
(microtime(true)-$time),
]);