Monday, July 19, 2010

PHP tutorial Part3

Posted by Syarif | Monday, July 19, 2010 | Category: |

Arithmetic Operator
There are several operator for Arithmetic that we use on PHP. Like others programming language, PHP have common operator.
(+) adder:
(-) subtract:
(/) divider :
(*) multiplier :
(%) mod:

For example:

<?
$a = 12;
$b = 2;
echo ("$a+$b=");
echo ($a+$b);
?>



TRUE AND FALSE
Compare the variable is used to make decision of the program. You can use the comparison for two objects or more.
For Example:

<?
$a = 12;
$b = 2;
echo ($a<$b);
?>



In example above, the value is TRUE. In PHP, it will be printed as “1” for TRUE.


<?
$a = 12;
$b = 2;
echo ($a<$b);
?>



As you know, the value of the comparison above is FALSE, so—the echo mode will not printed it on your webpage.

There are several symbol of comparison which is used in PHP:
• == : equal to
• != : not equal to
• < : less than • > : more than
• <= : less or equal to • >= : more or equal to

INCREMENT AND DECREMENT
You can increase and decrease your variable value with simply code.
For example:

<?
$a = 1;
$b = $a++; // the value is equal to $a+1;
$c = $a--; //the value is equal to $a -1;
?>

Currently have 0 comments:


Leave a Reply