PHP and php arithmetic operators. PHP arithmetic operators, php arithmetic operator PHP arithmetic operator name description instance result x + y plus x and y and 2 + 24x-y minus x and y difference 5-23x * y multiply x and PHP arithmetic operator, php arithmetic operators
PHP arithmetic operators
Operator |
Name |
Description |
Instance |
Result |
X + y |
Add |
Sum of x and y |
2 + 2 |
4 |
X-y |
Subtraction |
Difference between x and y |
5-2 |
3 |
X * y |
Multiplication |
Product of x and y |
5*2 |
10 |
X/y |
Division |
Vendors of x and y |
15/5 |
3 |
X % y |
Modulo (remainder of division) |
X divided by the remainder of y |
5% 2 10% 8 10% 2 |
1 2 0 |
-X |
Invert |
X inversion |
-2 |
|
A. B |
Collocated |
Connect two strings |
"Hi". "Ha" |
HiHa |
The following example demonstrates different results obtained using different arithmetic operators:
Run
Related reading:
Php strstr checks whether a string exists in the same string.
The php stristr () function finds the first occurrence of a string in another string.
The php strchr () function finds the first appearance of a string in another string.
Usage of strncasecmp, a comparison function between two php strings
Php strcasecmp compares two strings to determine if they are equal (compares the size of the two strings)
Http://www.bkjia.com/PHPjc/1129455.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1129455.htmlTechArticlePHP 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 by x and...