Wednesday, November 14, 2012

Learning PHP - Assignment, Comparison and If

Assignment Operator

In PHP, " = " does not mean equal. It assigns the value from the right of the expression to the left operand.

example: $a = 1000  $a gets set to 1000 ( the value of "$a = 1000" is 1000 )


Comparison Operator

If you want to use equal, this is the operator: = =

example: $a = = $b  ( TRUE if $a is equal to $b )



If Statement

Syntax:  if ( expression or condition )
          statement

If  condition is TRUE, statement will be executed. If condition is FALSE, statement will be ignored.
 
example:

             //This will print the value of $a on the screen if $a is equal to $b.

              if ( $a = = $b );
              print $a ;

     

              Sample Program:



                Output:



Learning PHP - Arithmetic Operators

Learning PHP - Constants

 

No comments:

Post a Comment

Popular Posts