Get the App
SLTechnology News&Howtos  ›  Development  › 

What operators does PHP have?

Shulou Source: shulou.com Published: 2022-06-02 19:37:07 11月09日 Update

This article will explain in detail what operators PHP has. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

1. Arithmetic operator

The PHP arithmetic operators are + (plus),-(minus), * (multiplication), / (division), and% (remainder).

two。 Assignment operator

The PHP assignment operators are + = (assign the value on the left plus the value on the right to the left),-= (assign the value on the left minus the value on the right to the left), * = (multiply the value on the left by the value on the right to assign to the left), / = (divide the value on the left by the value on the right to assign to the left),% = (assign the value on the left to the value on the right), . = (concatenate the string on the left to the right and assign a value to the left).

3. String operator

The PHP string operator has only the concatenation symbol ".", which concatenates two strings.

4. Self-increasing and self-subtracting operator

The PHP self-increment and self-subtraction operator comes in four forms: $aqure operator; + + $an operator; $a muri operator;-- $a.

5. Logical operator

The PHP logical operator has! (logic is not), and (logic and), & & (logic and), or (logic or, the result is true as long as one of the two expressions is true), | (logical OR), xor (XOR, the result is true if one of the two expressions is true).

& & and | | have a higher priority than and and or.

6. Bit operator

The bit operator is calculated by converting all numbers into binary numbers.

The bitwise operators are & (bitwise and), | (bitwise OR), ^ (bitwise XOR), (bitwise right shift), and ~ (bitwise inverse).

7. Relational operator

The relational operators are = (equal to),! = (not equal to), (greater than), and = (greater than or equal to).

8. Other operators

The PHP operator also has some operators, such as $(variable symbol), & (variable pointer, address), @ (before the function, no error message is displayed),?: (ternary operator), (comma operator),-> (methods and properties of objects), and = > (array assignment).

9. Operator precedence

PHP operators have precedence, and when multiple operators are together, the priority is calculated first. The simple understanding is to multiply and divide and then add and subtract, so I won't repeat it here.

This is the end of this article on "what operator does PHP have". I hope the above content can be of some help to you so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Operators operations logic right precedence characters two strings articles variables only more symbols results expressions good practical multiplication and division binary information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno NVidia Redmi MariaDB Apple