Saturday, September 11, 2010

PHP Operators

  • Operators are used to operate on values.
  • There are in php Arithmetic operators,Logical operator,Assignment operator,Comparison operator are available.
Arithmetic Operator :
Arithmetic operators are used to perform some arithmetic operation on with the variable in the task.
Operator Description Example Result
+ Addition x=2,x+2 4
- Subtraction x=2,5-x 3
* Multiplication x=4,x*5 20
/ Division 15/5,5/2 3,2.5
% Modulus 5%2,10%8 1,2
++ Increment x=5,x++ 6
-- Decrement x=5,x-- 4

Assignment Operator :
Assignment operator is used to assign value to the variable.

operator Example Is the same
= x=y x=y
+= x+=y x=x+y
-= x-=y x=x-y
*= x*=y x=x*y
/= x/=y x=x/y
.= x.=y x=x.y
%= x%=y x=x%y

Comparison Operator:
Comparison operators used to compare two variable with operator which will mostly used in conditions where return value will be true or false.
Operator Description Example
== Is equal to 5==8 returns False
!= Is not equal 5!=8 returns True
> Is greater than 5>8 returns False
< Is less than 5<8 returns True
>= Is greater than or equal to 5>=8 returns False
<= Is less than or equal to 5<=8 returns True

Logical Operator:
Logical operators are use to make condition which will return true or false.
Operator Description Example
&& And x=2,y=3,(x<10 && y>1)Returns True
|| OR x=50,y=3,(x<10 || y>1)Returns False
! NOT x=50,y=3,(x!=y)Returns True

1 comment:

  1. Thanks A Lord For Publish In Your Blog, This Is A Great Things To Learned Many Information. Keep Posting Many Blogs Like This.
    Web portal development company in chennai, Web portal development services in chennai

    ReplyDelete