What operators are there in php

DDD
Release: 2023-08-16 15:17:59
Original
1842 people have browsed it

php operators include: 1. Arithmetic operators, addition, subtraction -, multiplication *, division /, remainder %; 2. Assignment operators, addition =, subtraction -=, multiplication *=, Division /=, remainder %=; 3. Comparison operators, equal ==, congruent ===, not equal!=, not equal!==, greater than>, less than<, greater than or equal to>=, Less than or equal to <=; 4. Logical operators, and && or and, or || or or, not! or not; 5. Bitwise operators, bitwise AND&, bitwise OR|, bitwise XOR^, Move left<<, right>>, etc.

What operators are there in php

The operating environment of this article: Windows 10 system, PHP8.1.3 version, Dell G3 computer.

There are many types of operators in PHP that can be used to perform various operations. Some common PHP operators are introduced below.

Arithmetic operators:

Addition operator ( ): used to add two numbers.

Subtraction operator (-): used to subtract the second number from the first number.

Multiplication operator (*): used to multiply two numbers.

Division operator (/): used to divide the first number by the second number.

Remainder operator (%): used to return the remainder of the division of two numbers.

Assignment operator:

Simple assignment operation (assign the value on the right to the variable on the left.

Additional assignment operator (=): used to add the value on the right to the variable on the left and assign the result to the variable on the left.

Subtraction assignment operator (-=): used to subtract the value on the right side from the variable on the left side and assign the result to the variable on the left side.

Multiplication assignment Operator (*=): Used to multiply the value on the right by the variable on the left and assign the result to the variable on the left.

Division assignment operator (/= ): used to divide the variable on the left by the value on the right and assign the result to the variable on the left.

Remainder assignment operator (%=): used Divides the remainder of the variable on the left by the value on the right and assigns the result to the variable on the left.

Comparison operators:

Equality operator (==): used to compare whether two values ​​are equal.

Congruent operator (===): used to compare whether two values ​​are equal and The types are the same.

Inequality operator (!=): used to compare whether two values ​​are not equal.

Inequality operator (!==): Used to compare whether two values ​​​​are not equal or have different types.

Greater than operator (>): Used to determine whether the value on the left is greater than the value on the right The value.

Less than operator (<): used to determine whether the value on the left is less than the value on the right.

Greater than Equal operator (>=): used to determine whether the value on the left is greater than or equal to the value on the right.

Less than or equal operator (<=): used to determine whether the value on the left Whether the value on the side is less than or equal to the value on the right side.

Logical operators:

And operator (&& or and): used Determine whether multiple conditions are true at the same time.

Or operator (|| or or): used to determine whether one of multiple conditions is true.

Non operator (! or not): used to determine whether the condition is false.

Bitwise operator:

Press Bitwise AND operator (&): used to AND each bit of two numbers.

Bitwise OR operator (|): used to perform an AND operation on two numbers Each bit is ORed.

The bitwise XOR operator (^) is used to XOR each bit of two numbers.

Left shift operator (<<): Shifts the binary number to the left by the specified number of digits.

Right shift operator (>>): Shifts the binary number to the left by the specified number of digits. Shifts a binary number to the right by the specified number of digits.

The above are some common PHP operators. You can choose the appropriate operator according to specific needs to perform the corresponding operations.

The above is the detailed content of What operators are there in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template