Sunteți pe pagina 1din 3

PHP Arithmetic Operators

Operator x+y x-y x*y x/y x%y -x a.b Name Addition Subtraction Multiplication Division Modulus Negation Concatenation Description Sum of x and y Difference of x and y Product of x and y Quotient of x and y Example 2+2 5-2 5*2 15 / 5 5%2 Remainder of x divided by 10 % 8 y 10 % 2 Opposite of x -2 Concatenate two strings "Hi" . "Ha" Result 4 3 10 3 1 2 0 HiHa

PHP Assignment Operators


The basic assignment operator in PHP is "=". It means that the left operand gets set to the value of the expression on the right. That is, the value of "$x = 5" is 5. Assignment Same as... x=y x += y x -= y x *= y x /= y x %= y a .= b x=y x=x+y x=x-y x=x*y x=x/y x=x%y a=a.b Description The left operand gets set to the value of the expression on the right Addition Subtraction Multiplication Division Modulus Concatenate two strings

PHP Incrementing/Decrementing Operators


Operator Name Description ++ x Pre-increment Increments x by one, then returns x x ++ Post-increment Returns x, then increments x by one -- x Pre-decrement Decrements x by one, then returns x x -Post-decrement Returns x, then decrements x by one

PHP Comparison Operators


Comparison operators allows you to compare two values: Operator x == y x === y x != y x <> y x !== y x>y x<y x >= y x <= y Name Equal Identical Not equal Not equal Not identical Description True if x is equal to y True if x is equal to y, and they are of same type True if x is not equal to y True if x is not equal to y True if x is not equal to y, or they are not of same type True if x is greater than y True if x is less than y True if x is greater than or equal to y Example 5==8 returns false 5==="5" returns false 5!=8 returns true 5<>8 returns true 5!=="5" returns true 5>8 returns false 5<8 returns true 5>=8 returns false 5<=8 returns true

Greater than Less than Greater than or equal to Less than or equal True if x is less than or equal to y to

PHP Logical Operators


Operator x and y Name And Description Example x=6 y=3 True if both x and y are true (x < 10 and y > 1) returns true x=6 True if either or both x and y are y=3 true (x==6 or y==5) returns true x=6 True if either x or y is true, but not y=3 both (x==6 xor y==3) returns false x=6 y=3 True if both x and y are true (x < 10 && y > 1) returns true x=6 True if either or both x and y are y=3 true (x==5 || y==5) returns false x=6 True if x is not true y=3 !(x==y) returns true

x or y

Or

x xor y

Xor

x && y

And

x || y

Or

!x

Not

PHP Array Operators


Operator x+y x == y x === y x != y x <> y x !== y Name Union Equality Identity Inequality Inequality Non-identity Description Union of x and y True if x and y have the same key/value pairs True if x and y have the same key/value pairs in the same order and are of the same type True if x is not equal to y True if x is not equal to y True if x is not identical to y

S-ar putea să vă placă și