You are on page 1of 1

Omar Carrillo

Solutions
Homework 2
Assignment

Problem 1
Problem 2

Problem 2 Without running it through the PHP interpreter, figure out what this program prints.

Problem 3 $age = 12;


$shoe_size = 13;
if ($age > $shoe_size) {
Problem 4 print "Message 1.";
} elseif (($shoe_size++) && ($age > 20)) {
Problem 5 print "Message 2.";
} else {
Problem 6 print "Message 3.";
}
Problem 7 print "Age: $age. Shoe Size: $shoe_size";

Problem 8
Solution

Analysis:

($age > $shoe_size) returns false


($age > 20) is false, thus, (($shoe_size++) && ($age > 20)) is false
So, it prints "Message 3."
Then prints $age, which is 12
Then prints $shoe_size which 14 since it was changed by the increment operator $shoe_size++.
Therefore, the output should be:

Message 3. Age: 12. Shoe Size: 14

CS 479 - PHP Programming - Summer 2009 - NMSU

PDF generated automatically by the HTML to PDF API of PDFmyURL

You might also like