Operators are used to operate on values.


PHP Operators

This section lists the different operators used in PHP.

Arithmetic Operators

OperatorDescriptionExampleResult
+Additionx=2
x+2
4
-Subtractionx=2
5-x
4
*Multiplicationx=4
x*5
20
/Division20/5
5/2
4
2.5
%Modulus (division remainder)5%2
10%8
10%2
1
2
0
++Incrementx=5
x++
x=8
--Decrementx=5
x--
x=4

Assignment Operators

OperatorExampleIs The Same As
=x=yx=y
+=x+=yx=x+y
-=x-=yx=x-y
*=x*=yx=x*y
/=x/=yx=x/y
.=x.=yx=x.y
%=x%=yx=x%y

Comparison Operators

OperatorDescriptionExample
==is equal to5==8 returns false
!=is not equal5!=8 returns true
>is greater than5>8 returns false
<is less than5<8 returns true
>=is greater than or equal to5>=8 returns false
<=is less than or equal to5<=8 returns true

Logical Operators

OperatorDescriptionExample
&&andx=8
y=4

(x < 10 && y > 1) returns true

||orx=8
y=4

(x==5 || y==5) returns false

!notx=8
y=4

!(x==y) returns true


Plaats een reactie
Bekijk reacties
Go to top

  



php operators


Free website & domain name provided by blogje.eu . C.M.S. & templates © Universalis . Hosted & powered by Shopje © 2003 - 2017 .
Laatst gewijzigd: 2007-11-04 Hits: