Operators in php programming

Source: Internet
Author: User
Regardless of the programming language, operators are the foundation of the program, and the important type is self-evident. Php programming is the same. we need to fully understand and master these operators and arithmetic operators.

Regardless of the programming language, operators are the foundation of the program, and the important type is self-evident. Php programming is the same. we need to fully understand and master these operators, arithmetic operators, logical operators, and so on. Only by mastering these operators can we write out excellent php source code. Let's take a look at the meaning of the operators in the php programming language.

1. numeric and character operators
+,-, *,/, In addition to %, there are also % operators that take the remainder, ++ accumulate, -- decrease character only one operator, that is, in English ". "point, used to connect the string, into a new string. for example: $ a = "You,"; $ B = "good"; $ c =? "; Echo $ a. $ B. $ c;

 

2. Next is the value assignment operator.
"=" Is assigned to the left
"+ =" To add the value on the right to the left
"-=" Indicates the value on the right minus the value on the left.
"* =" Multiply the left side to the right side
"/=" The value on the left is divided by the value on the right.
"% =" Returns the remainder of the left value pair's right value.
". =" Adds the string on the right to the left
The value assignment operator can simplify the code, and more importantly, it can be more efficient than the first operation and then the value assignment.

3. logical operators-generally used to test the true and false values

<,>, <=, >=, "=" Indicates whether the values on both sides are equal.
"===" To determine whether the types and values on both sides are equal
"! = "When the two sides are not equal
"&" Or "and" determines whether the two packets are true (and the operation is performed)
"|" Or "or "........................ Or operation
"Xor" determines whether the real values on both sides are different
"!" When the value is false

4. bitwise operators is used for some fast numeric operations. There are 6 operators in total.

"&" Bitwise and operation
"|" Bitwise OR operation
"^" Bitwise XOR operation
"<" Shifted to the left, such as. $ a <">" shifted to the right.
"~" Bitwise inversion is like ~ $

5. other operators

"$" Variable
& Takes the variable address
"@" Hides the error message
"->" Method or attribute of the object
"=>" Array element value
"? : "Is used to determine (exp1 )? (Exp2) :( exp3) if exp1 is exp2; otherwise, exp3
Priority
In php, like all languages, the priority is higher first, and the priority is lower.
Operations with the same priority are performed from left to right, and parentheses are referenced to control the operation sequence. any operation with the same priority is the highest.
1. or, and, xor
2. value assignment operator
3. "| ","&&"
4. "|", "^"
5. "&", "."
6. +,-(addition and subtraction operators)
7. "/", "*", "%"
8. "<", ">"
9. "++ ","-"
10. "+", "-" (plus or minus sign operator)
11. "= ","! = "," <>"
12. "<", "<=", ">" "> ="
13. "? :"
14. "->"
15. "=>"

If you have encountered various problems in php programming, please leave a message at the bottom of the screen or on the message board. we will reply to your problem as soon as possible (no more than 24 hours ).

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.