Comparison Operators in php _ PHP Tutorial

Source: Internet
Author: User
Detailed description of comparison operators in php. 1. for arrays $ aarray (1, 2, 3, 6); $ barray (1, 2, 3, 6, 8); echon; var_dump ($ a $ B ); var_dump ($ a $ B); result: booleanfalsebooleanfalsebooleantrueps: Has

1. for arrays
$ A = array (1, 2, 3, 6 );
$ B = array (1, 2, 3, 6, 8 );
Echo "\ n ";
Var_dump ($ a> $ B );
Var_dump ($ a = $ B );
Var_dump ($ a <$ B );

Result:
Boolean false
Boolean false
Boolean true

Ps: the array with fewer members is small.

$ A = array (1, 2, 3, 6, 9 );
$ B = array (1, 2, 3, 6, 8 );
Echo "\ n ";
Var_dump ($ a> $ B );
Var_dump ($ a = $ B );
Var_dump ($ a <$ B );
Boolean true
Boolean false
Boolean false

Ps: case-by-case comparison

$ A = array (1, 2, 3, 6, 'B' => 3 );
$ B = array (1, 2, 3, 6, 8 );
Echo "\ n ";
Var_dump ($ a> $ B );
Var_dump ($ a = $ B );
Var_dump ($ a <$ B );
Boolean false
Boolean false
Boolean false

Ps: If the key in Operation Number 1 does not exist in Operation number 2 and the array cannot be compared, false is returned.

2. Comparison between bool or null and other types

Var_dump (bool) (null); // boolean false // false when the value of null is converted to bool;

Convert null and other types to bool, and then compare, and FALSE <TRUE

Outputs $ a = array (,); $ B = array (, 8); echo "\ n"; var_dump ($ a $ B ); var_dump ($ a ==$ B); var_dump ($ a $ B); result: boolean false boolean true ps:...

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.