PHP PHP Basics PHP on the Web Final Quiz

ella ukpo
ella ukpo
369 Points

Final Quiz

$a = 1;
if ($a > 1) {
    $a--;
    $a += 2;
} elseif ($a < 1) {
    $a++;
} else {
    $a += 5;
}
$a = $a + 2;
echo $a;
Rich Donnellan
Rich Donnellan
Treehouse Moderator 25,634 Points

Question updated with code formatting. Check out the Markdown Cheatsheet below the Add an Answer submission for syntax examples.

1 Answer

Steven Parker
Steven Parker
176,295 Points

Try writing the entire thing on a piece of paper (using separate lines as in the original), and then, one step at a time, write down what value $a would have after that step. Skip any step that would not run because of a conditional (if/elseif/else) test. Then when you get to the last line, you should have the correct answer.