PHP3 Chinese Document (cont. 5)

Source: Internet
Author: User
Tags arithmetic arithmetic operators bitwise operators comparison expression integer integer division logical operators
Chinese arithmetic operator





These jobs are similar to those taught in basic schools.





 





Table 7-1. Arithmetic Operators (table 7-1 arithmetic operator)





Example Name result


$a + $b addition Sum of $a and $b.? /FONT>


$a-$b subtraction remainder of $b subtracted from $a.? /FONT>


$a * $b multiplication Product of $a and $b.? /FONT>


$a/$b division dividend of $a and $b.? /FONT>


$a% $b modulus remainder of $a divided by $b.





 





where the division operator "/" returns an integer value (the result of integer division) if two operands are integers (or strings that are converted to integers). If any of the operands are floating-point numbers, floating-point operations are performed.





string operator





This place has only one real string operator: concatenate symbol ".".





 





$a = "Hello"; $b = $a. " World! ";





//Now $b = "Hello world!"





Assignment operator





the basic assignment operator is "=". You tend to think that it means "equals". Don't think like that, it really means that the left-hand operand gets the value of the right expression.





 





the meaning of an assignment expression is the assignment of a value. In other words, the value of "$a = 3" is 3. This allows you to do things like this:





 





$a = ($b = 4) + 5;





//$a is equal to 9 now, and $b has been set to 4.





 





as a supplement to the assignment operator, there is also a combination operator for binary numbers and word Fu, which allows you to use the value of an assignment expression on the assignment. For example:





 





$a = 3;





$a + 5; Sets $a to 8, as if we had said: $a = $a + 5;





$b = "Hello";





$b. = "there!"; Sets $b to "Hello there!" and just like $b = $b. "There!";





bit operator




The
bit operator allows you to fine manipulate each bit of data.





 





Table 7-2. Bitwise Operators (table 7-2-bit operator)





Example Name result


$a & $b and Bits are set in both $a and $b are set.? /FONT>


$a | $b or Bits that are set in either $a or $b are set.? /FONT>


~ $a?/font> not Bits so are set in $a are not set, and vice versa.





logical operator





Table 7-3. Logical Operators (table 7-3 logical operators)





 





Example Name result?/font>


$a and $b and true of both $a and $b are true.? /FONT>


$a or $b or?/font> true if either $a or $b is true.? /FONT>


$a xor $b or?/font> true if either $a Or $b is True, but not both.? /FONT>


! $a not?/font> True if $a is not True.? /FONT>


$a && $b and?/font> true of both $a and $b are true.? /FONT>


$a | | $b or?/font> True if either $a Or $b is True.





comparison operator




The
comparison operator, as its name shows, allows you to compare two values.





 





Table 7-4. Comparson Operators (table 7-4 comparison operator)





Example Name result?/font>


$a = = $b equal?/font> True If $a is Equal to $b.? /FONT>


$a!= $b not equal True if $a was not equal to $b. /FONT>


$a < $b less than?/font> True If $a is strictly less than $b.? /FONT>


$a > $b Greater than?/font> True If $a is strictly Greater than $b.? /FONT>


$a <= $b less than or equal to?/font> True if $a is less than or equal to $b. /FONT>


$a >= $b Greater than or equal to?/font> True if $a is Greater than or equal to $b.














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.