Bitwise and/or operations in PHP

Source: Internet
Author: User
Bitwise and operations are mainly performed on binary numbers. The code is as follows: [php] & lt ;? Php $ a = 1; $ B = 2; $ c = $ a ^ B; echo $ c3? & Gt; here we do not simply convert the addition relationship decimal 1 to binary 00000001 decimal 2 to binary 00000010 bitwise and mainly operate on binary numbers. The code is as follows: [php] Here we do not simply convert the add-on relationship decimal 1 to binary 00000001 decimal 2 to binary 00000010 ^ 00000011 by bit // the values of different values are regarded as 1 ^. then, [html] Convert decimal 3 to binary 00000011 decimal 1 to binary 00000001 bitwise & 00000001 // it means that each digit remains the same; otherwise, it is regarded as 0; the return value after bitwise & is meaningless. It is mainly used to determine whether $ a exists in $ c. // There are many permission usage options. [Html] 'Add', 4 => 'Delete', 2 => 'change', 1 => 'query'); foreach ($ privilege_arr as $ k => $ v) {$ k & $ my_privilege & $ Pri. = 'I '. $ v. 'Power
';} Echo $ Pri;?>

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.