Logic errors are the hardest to find and fix on every programming languages.
These are errors that make your program do what is not intended to do.
One of the common mistakes that you may encounter many times on your program is the use of equal assignment operator for the purpose of using equal comparison operator.
This is because comparison operator is used to test if two values are equal. It returns a boolean value of either true, which is equivalent to nonzero value, or false, which is equivalent to zero value in boolean. While the assignment operator produces an output value which is equal to the value of the left variable on the operation, you may commit a logic error on your conditional statement.
For example:
$a = 3;
$b = 5;
echo $a == $b; //output is false
echo $a = $b; //output is 5 which is true on boolean
So if you will use it to your conditional statements, you will produce an error that will take you time to find and fix.
Another example for conditional statement effects:
if( $skillPoints == 100 ){
//give your employees a salary raise
}
and if you use this:
if( $skillPoints = 100 ){
//give your employees a salary raise
}
Cool! You definitely got a salary raise by your mistake. =D
__________________________________________________
Web Programming Tutorial by Gerlie Mendoza | Web Developer
http://on.fb.me/Ay7OPZ