PHP arithmetic operators, PHP arithmetic operators
PHP arithmetic operators
| operator |
name |
Description |
Example |
Results |
| X + y |
Add |
X and Y's and |
2 + 2 |
4 |
| X-y |
Reducing |
The difference between x and Y |
5-2 |
3 |
| X * y |
By |
The product of X and Y |
5 * 2 |
10 |
| X/Y |
Except |
Quotient of X and Y |
15/5 |
3 |
| X% y |
Modulo (remainder of division) |
The remainder of x divided by Y |
5% 2 10% 8 10% 2 |
1 2 0 |
| -X |
Take counter |
X inverse |
-2 |
|
| A. B |
collocated |
Connect two strings |
"Hi". "Ha" |
Hiha |
The following example shows the different results obtained using different arithmetic operators:
Run
Related reading:
PHP strstr determine if a string exists in a string
The PHP stristr () function finds the first occurrence of a string in another string
The PHP strchr () function finds the first occurrence of a string in another string
PHP two string comparison function strncasecmp How to use a detailed
PHP strcasecmp compares two strings for equality (compares the size of two strings)
http://www.bkjia.com/PHPjc/1129455.html www.bkjia.com true http://www.bkjia.com/PHPjc/1129455.html techarticle PHP arithmetic operator, PHP arithmetic operator PHP arithmetic operator name Description instance result x + y plus x and y and 2 + 2 4 x-y minus x and y difference 5-2 3 x * y multiply x and ...