Welcome! In this section we going to cover differect kinds of operators we use in programming. These operators are common to ever language. So, in PHP they are no diffrent. We will go through each type of operators with examples on how they are done PHP.
|Learn PHP and MySQL fast!|
Learn how you can start building rich interactive database driven sites like a professional developer easily and quickly...
>> Order your copy now for just $39.95 <<
In programming, we often perform arthmenteic operations to calculate values. Below is the list of these oprators with examples.
$num = 5+5;
$num = 5-5;
$num = 5*5;
$num = 5/5;
Comparison Operators prove very useful when checking the status of two variables or values. For example, if you wna tto check if one is equal to the other, we would use = operator. Comparasion operators are used in logic conditional statements (check PHP If...else section) to evalute if the condition is true or false.
|>||is greater than||
6 > 5
5 > 6
First example returns true.
Second example returns false.
|<||is less than||
6 < 5
5 < 6
First example returns false.
Second example returns true.
|>=||is greater than equal to||
5 >= 4
|<=||is less than equal to||
5 <= 4
|==||is equal to||
5 = 4
|!=||is not equal to||
5 != 4
Logic operators can be used to combine two or more comparision statements combined into one statement to determine its status. For example, we can check to see if value A greater than value B and value B greater then value C. Let's check out some examples.
|&&||and||(6 > 5 && 1 < 7)||returns true|
|||||or||(2 > 5 || 1 < 7)||returns true|
If you're not familiar with the logic operations and their usage, please refer to the table below for reference. The table shows what you would get back when performating logic operatioon on two values p and q where T = True and F = False.
|p||q||p and q||p or q|
Build large scalable dynamic websites using PHP yourself
Learn PHP like a pro >>
|<< PHP Strings||Top||PHP If...Else >>|