Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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 27,696 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
231,268 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.