PHP中的类型约束介绍
PHP的类方法和函数中可实现类型约束,但参数只能指定类、数组、接口、callable 四种类型,参数可默认为NULL,PHP并不能约束标量类型或其它类型。如下示例:复制代码 代码如下:<?phpclass Test{ public function test_array(array $arr) { print_r($arr); } public function test_class(Test1 $test1 = null) { print_...