PHP Beginner's operator

Source: Internet
Author: User
PHP Beginner's operator
Operations must have results
One, arithmetic operators
1, +-*/; corresponds to the subtraction in mathematics, similar to $a= $b + $c is not affected by the value type when dividing
2,%; redundancy, modulus; the remainder is like 5%3, and the final result is 2, and the remainder of that value after the division is divisible.
In the modulo operation, the positive and negative results of the operation depend on the sign of the divisor.
Second, the comparison operator;> greater than, <小于,> = Greater than or equal, <= is less than or equal,! = is not equal to = = equals, = = = is equal to (not only value equal even data type),!== is not all equal to
Three, string operators; only one function, concatenation of strings, in the form of. Point
assignment operator; = Assigning the value to the right to the left variable
Five, logical operators;
1. Logic or | | Or OR, one of several conditions can be established.
2, logic and && or and, a number of conditions must be established in order to
3 Priority;&& of logical operations Priority ratio | | High
Six, the logic counter;! When you make logical judgments, add! , which means to judge the logical inverse of the parameters of judgment.
VII, XOR two conditions must be true a false case only true
Eight or three-dollar operator, condition? Return value 1: Return value 2, return value 1 if condition is true, return return value 2 if condition is false, function similar to if{}else{}
Nine, increment decrement operator; + + + 1 、--minus 1 on the left side of the variable, the first operation is re-used, and at the right of the variable, the first operation
Ten, bit operations, binary + logical operations
e.g. 5=4+1;
=1*4+0*2+1*1
=1*2^2+0*2^1+1*2^0
=101 (2)
The computer uses 0/1 to store information. A unit that can store 0/1 is called a bit (bit), 8 bits constitute a byte, the byte is the most basic unit of the computer, when 5 of the binary only accounted for 3 bits, in order to let the computer can read, so the format of the input is 0000 0101, that is, the poor bit with 0 padding
In other words, 0/1 is the stroke of the Chinese characters, in the computer requires a Chinese character must have 8 paintings, but some Chinese characters with 3 strokes on the finish, this time it is necessary to use a fixed stroke to do the filling,
& (and), aligning two binary values, 1 as true, 0 as false, and operations on each one, such as;
12=0000 1100
5 = 0000 0101
12&5=0000 0100=4
| (or); Two binary values aligned, 1 as true, 0 as false, on each one to do or the operation, such as;
12=0000 1100
5 = 0000 0101
12|5=0000 1101=13
^ (XOR); align two binary values, treat 1 as true, 0 as false, and perform XOR operations on each one, such as;
12=0000 1100
5 = 0000 0101
12|5=0000 1001=9
~ (anti); there is already a binary value, 1 as true, 0 as false, on each one to do the inverse of the operation, such as;
12=0000 1100
~ = 1111 0011=-13
Note: The complement rule,
1, binary, the highest position is positive or negative, 0 is positive, 1 is negative, for example, 1111 0011 is the first bit of sign, that is, positive and negative number
2, the absolute value of the remaining 7 bits. For example, () 111 0011=115
3. Subtract 2^7 from this absolute value. such as 115-128=-13
4, 1000 0000== "-128
1111 1111== "-1
0000 0000== "0
0111 1111== "127
Xi. shift operation;
<<; a eight-bit binary value, to the left, to add (0) to the right, to generate a new value
such as; 5 = 0000 0101
5<<1 = 0000 1010=10, remove one bit to the left, add one bit from the right (0)
>>; a eight-bit binary value that is removed to the right and added from left (0) to generate a new value
such as; 5 = 0000 0101
5>>1 = 0000 0010=2, remove one bit to the right, add one bit from the left (0)

The above introduces the PHP beginner operators, including the content, I hope the PHP tutorial interested in a friend helpful.

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