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 ());p Rint_r ($ Test->arr); output Array ([0] = Included object () [1] = = Included object () [2] = = Included object ())
BOOL In_array (mixed $needle, array $haystack [, bool $strict = FALSE])
If the value of the third parameter strict is TRUE then the In_array () function also checks whether the needle type is the same as in haystack.
Whether this type can be understood as an object instance. Because the above example In_array () the third parameter by default, only the output
Array ([0] = Included Object ())
Reply to discussion (solution)
Yes, this type also includes object instances
Well, thank you so much.
Third??? Is it the same type?
For example:
Thank you upstairs, but this type is the same as whether it contains object instances, this PHP manual does not have this description.
This is described in the manual.
If the value of the third parameter strict is TRUE then the In_array () function also checks whether the needle type is the same as in haystack.
That type is a link, which is then opened.
You don't need to elaborate, do you?
Bright, the results you measured are also included in the object.
OK, thank you.