Introduction
An operator is used to operate on values. In a basic example, we use an addition operator to add 1+9 together. In another basic example, we use a subtract operator to take away 1 from 10 (10-1). PHP Operators are split into the following categories and shall be explained later in the article:
*Arithmetic Operators
*Assignment Operators
*Comparison Operators
*Logical Operators
Arithmetic Operators
1.Addition (+), eg: x+y
2.Subtraction (-), eg: x-y
3.Multiplication (*), eg: x*y
4.Division (/), eg: x/y
5.Modulus (%), eg: x%y
6.Increment (++), eg x++
7.Decrement (--), eg y--
Assignment Operators
1. =, eg: x=y
2. +=, eg: x+=y, AKA: x=x+y
3. -=, eg: x-=y, AKA: x=x-y
4. *=, eg: x*=y, AKA: x=x*y
5. /=, eg: x/=y, AKA: x=x/y
6.%=, eg: x%=y, AKA: x=x%y
Comparison Operators
1.Not equal to (!=), eg: 18!=13 returns true
2.Greater than (>), eg: 18>13 returns true
3.Less than (<), eg: 18<13 returns false
4.Greater than or equal to (>=), eg: 18>=13 returns true
5.Less than or equal to (<=), eg: 18<=13 returns false
Logical Operators
1.And (&&), eg: (1<2>4) returns true
2.Or (), eg: (1==5 2==10) returns false
3.Not (), eg: !(5==10) returns true
Conclusion
Operators are mainly seen during assignment of a value to a variable or during a conditional statement or a looping structure. They are very powerful are can be used to determine the output of a script, procedure or function to be run.
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment