Question of the third parameter of the In_array () function

Source: Internet
Author: User
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.