Posted inphp

php get class name without namespace – PHP Namespaces

php get class name without namespace – get a PHP class name without the use of namespace and without using reflection.

php get class name without namespace

simple function to get class name without namesapce. php get class name without namespace from string

public function getClassName() {
    $path = explode('\\', __CLASS__);
    return array_pop($path);
}
return substr(strrchr(__CLASS__, "\\"), 1);

PHP get class name without namespace

public function getName() {
    $path = explode('\\', __CLASS__);
    return array_pop($path);
}

php namespace class


laravel get class name

$lObjectect = $em->find(ContactRelation::class, $userId);
echo get_class($lObjectect);
// Some\Name\Space\Domain\Identity\ContactRelation

Don’t Miss : PHP Config Class To Store Configuration Data

I hope you get an idea about php get class name without namespace.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype