02.2b: Bug Types
Software written by even the most seasoned software developer will still have bugs. In this lesson, we look at the two most common types of software bugs: Syntax bugs and logic bugs.
<?php # * ------------------------------------------------- # * Types of bugs; syntax vs logic # * ------------------------------------------------- # * Syntax bug $j = 5 $n = $j + 5; print "n: $n\n"; # * ------------------------------------------------- # * Logic bug $a = 5; $b = 3; $sum = $a + $b; print "sum of $a + $b = $sum\n"; # * Mars rover miles vs kilometers. $m = 1; $k = $m * 1.6; print "There are $k kilometers in $m mile(s).\n"; # * ------------------------------------------------- # * How to debug? # * Calculate total square footage of 2 rooms: $height1 = 10; $width1 = 10; $height2 = 10; $width2 = 20; $room1_sq_ft = $height1 * $width1; $room2_sq_ft = $height2 + $width2; $total_sq_ft = $room1_sq_ft + $room2_sq_ft; print "Total sq ft: $total_sq_ft\n"; ?>