<?php
class Foo {
function dump() {
var_dump(get_class($this));
var_dump(self::class);
var_dump(get_class());
var_dump(get_class(null));
}
}
(new Foo())->dump();
string(3) "Foo"
string(3) "Foo"
Deprecated: Calling get_class() without arguments is deprecated in /in/GI5Kc on line 7
string(3) "Foo"
Fatal error: Uncaught TypeError: get_class(): Argument #1 ($object) must be of type object, null given in /in/GI5Kc:8
Stack trace:
#0 /in/GI5Kc(12): Foo->dump()
#1 {main}
thrown in /in/GI5Kc on line 8
Process exited with code 255.
string(3) "Foo"
string(3) "Foo"
string(3) "Foo"
Fatal error: Uncaught TypeError: get_class(): Argument #1 ($object) must be of type object, null given in /in/GI5Kc:8
Stack trace:
#0 /in/GI5Kc(12): Foo->dump()
#1 {main}
thrown in /in/GI5Kc on line 8
Process exited with code 255.
Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /in/GI5Kc on line 6
Process exited with code 255.