php get class name without namespace code example
Example 1: laravel get class name
$myObject = $em->find(ContactRelation::class, $userId);
echo get_class($myObject);
// Some\Name\Space\Domain\Identity\ContactRelation
Example 2: php namespace class
<?php
namespace m\name; // see "Defining Namespaces" section
class MyClass {}
function myfunction() {}
const MYCONST = 1;
$a = new MyClass;
$c = new \my\name\MyClass; // see "Global Space" section
$a = strlen('hi'); // see "Using namespaces: fallback to global
// function/constant" section
$d = namespace\MYCONST; // see "namespace operator and __NAMESPACE__
// constant" section
$d = __NAMESPACE__ . '\MYCONST';
echo constant($d); // see "Namespaces and dynamic language features" section
?>