class Included{}class test{ public $arr = array(); function a(Included $include){ if (in_array($include, $this->arr, true)){ return; } $this->arr[] = $include; }}$test = new test();$test->a(new Included());$test->a(new Included());$test->a(new Included());print_r($test->arr); // 输出Array ( [0] => Included Object ( ) [1] => Included Object ( ) [2] => Included Object ( ) )
是的,这个类型同样包括对象实例
恩,谢谢您了。
第三???是?查是否相同?型的。
例如:
<?php$a = 123;$arr = array('123','456');var_dump(in_array($a, $arr)); // truevar_dump(in_array($a, $arr, true)); // false?>谢谢楼上,但是这个类型相同是否是包含对象实例,这个php手册里没有这方面的描述。
手册中是这样描述的
如果第三个参数 strict 的值为 TRUE 则 in_array() 函数还会检查 needle 的 类型是否和 haystack 中的相同。
那个类型是个链接,点开后是
这就不需要再细说了吧?
而况你实测的结果也是包括对象的
好的,谢谢了。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号