Menu Samaritan's Purse

GET_CLASS

Returns the name of the class of an object

SYNTAX

get_class ([ object $object ] ) : string

PARAMETERS

object

The tested object. This parameter may be omitted when inside a class.

Note: Explicitly passing NULL as the object is no longer allowed as of PHP 7.2.0. The parameter is still optional and calling get_class() without a parameter from inside a class will work, but passing NULL now emits an E_WARNING notice.

RETURN

Returns the name of the class of which object is an instance. Returns FALSE if object is not an object.

If object is omitted when inside a class, the name of that class is returned.

If the object is an instance of a class which exists in a namespace, the qualified namespaced name of that class is returned.

EXAMPLES

VOID

myclass

OBJECT | INTERNAL CALL

myclass

OBJECT | EXTERNAL CALL

myclass

1

myclass2
myclass1

2

mynamespace\myclass

PHP