Easy access to PHP logical operator syntax and technical _php tutorials

Source: Internet
Author: User
Tags bit set bitwise operators constant definition
PHP has a lot to learn, here we mainly introduce the PHP logical operators, including the introduction of bit operators, comparison operators and so on. The bitwise operator allows you to set the bits specified in the integer number. If both the left and right arguments are strings, the bitwise operator will manipulate the characters in the string.

bitwise operators of 1.PHP logical operators :

 
  
  
  1. &: $a & $b and (bitwise AND) will have a 1 bit set to 1 in both $a and $b.
  2. |: $a | $b or (bitwise OR) sets the bit to 1 for 1 in the $a or $b.
  3. ^: $a ^ $b Xor (Bitwise XOR) will set the different bits in the $a and $b to 1.
  4. ~:~ $a not (bitwise non) sets the bit in the $a to 0 and vice versa.
  5. < < << $b Shift left moves the bits in the $a to the left $b times (each move represents "multiplied by 2").
  6. > >

Bit operation symbols involve microscopic bit changes, for example 5&3 so 5 of the storage binary code is 0110 3 of the storage binary code is 0100 then 5 and 3 do the logic and budget is

 
  
  
  1. 0101
  2. 0011

So the result is still 1, the example is as follows:

 
 
  1. <html>
  2. <head>
  3. < title > PHP constant Definition--Tao essay title>
  4. head>
  5. <body>
  6. php
  7. $ a = 5 ;
  8. $ b = 3 ;
  9. $ C = $a & $b;
  10. echo $c. " <br> ";
  11. Echo 5&3;
  12. ?>
  13. body>
  14. html>

In order to calculate the need of binary knowledge, general operation is not in place.

comparison operators for 2.PHP logical operators :

Comparison operators, as their names imply, allow you to compare two of values

 
  
  
  1. Falsh
  2. = = = Strict return value TRUE or Falsh (PHP 4 only)
  3. ! =: Unequal return value TRUE or Falsh
  4. < > : Unequal return value TRUE or Falsh.
  5. !==: Non-congruent return value TRUE or Falsh. PHP 4 only).
  6. < : Small and non-congruent return value TRUE or Falsh.
  7. > : is greater than the non-congruent return value TRUE or Falsh.
  8. < =: Non-congruent return value TRUE or Falsh.
  9. >

The comparison is returned after the Boolean = = and = = = The difference is that the former only compares the value, not the comparison type such as 1 and ' 1 ' is considered to be the same, and = = = Compare the value and the comparison type. Error control operator (@) PHP supports an error control operator: @. Any error messages that may be generated by the expression are ignored until it is placed in a PHP expression. If the track_errors attribute is activated, any error information generated by the expression is stored in the variable $php _errormsg. This variable is overwritten every time an error occurs, so check it out as soon as possible if you want to use it. The above is a simple introduction of the PHP logical operators, we hope to be helpful.


http://www.bkjia.com/PHPjc/446485.html www.bkjia.com true http://www.bkjia.com/PHPjc/446485.html techarticle PHP has a lot to learn, here we mainly introduce the PHP logical operators, including the introduction of bit operators, comparison operators and so on. The bitwise operator allows the specified bit in the integer number to be entered ...

  • 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.