Syntax:string Reflection::getName (void)
Parameters:This function does not take any parameters.
Returned value:This function returns the name of the specified class.The following programs illustrate the Reflection function::getName() in PHP:
Program 1:
// Define a custom class named Departments
class
Departments {
public
$Dept1
=
’CSE’
;
private
$Dept2
=
’ECE’
;
public
static
$Dept3
=
’EE’
;
}
// Using ReflectionClass over the Departments class
$ReflectionClass
=
new
ReflectionClass (
’Departments’
);
// Call the getName() function
$A
=
$ReflectionClass
-> getName();
// Get the name of the specified class
var_dump (
$A
);
?>
Output: string (11) "Departments"
Program 2:
// Using ReflectionClass over built-in class ’ ReflectionClass & # 39 ;
$ReflectionClass
=
new
ReflectionClass (
’ReflectionClass’
);
// Call the getName() function
$A
=
$ReflectionClass
-> getName();
// Get the class name
var_dump (
$A
);
?>
Output: string (15) "ReflectionClass"
Link: https://www.php.net/manual/en/reflectionclass.getname.php