**一.作用** #get\_debug\_type函数是对gettype函数的改进和尝试. ~~~ gettype() get_debug_type() ~~~ **二.get\_debug\_type和gettype区别** #get\_debug\_type对面向对象的类型判断更为精确. 1.标量类型 ~~~ string "Foo" array [1, 2] null null int 123 float 3.141 bool true ~~~ 2.类对象和匿名函数 ~~~ 类对象 new stdClass() 类对象 new DateTime() 类对象 new Foo\Bar() 函数闭包 function() {} 匿名类 new class {} 匿名子类 new class extends Foo{} ~~~ 3.资源类型 ~~~ 文件流 fopen(); ~~~ **三.实例代码** 1.类对象 new Foo\\Bar() ~~~ namespace Foo; class Bar{} $foo=new Bar; var_dump(gettype($foo)); echo '<br>'; var_dump(get_debug_type($foo)); ~~~ 2.函数闭包 function() {} ~~~ $foo=function(){}; var_dump(gettype($foo)); echo '<br>'; var_dump(get_debug_type($foo)); ~~~ 3.匿名类 new class {} ~~~ $foo=new class{}; var_dump(gettype($foo)); echo '<br>'; var_dump(get_debug_type($foo)); ~~~ 4.匿名子类 new class extends Foo{} ~~~ class Foo{} $foo=new class extends Foo{}; var_dump(gettype($foo)); echo '<br>'; var_dump(get_debug_type($foo)); ~~~