多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
**一.作用** #get_debug_type函数是对gettype函数的改进和尝试. ``` gettype() get_debug_type() ``` &emsp; **二.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(); ``` &emsp; **三.实例代码** 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)); ``` &emsp; **配套的PHP8新特性详解视频教程,请查看以下专辑** 链接:[https://www.ixigua.com/6937490165329822219](https://www.ixigua.com/6937490165329822219)