PHP review questions

Is the following program correct?


<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Conditionals review question
Author: Elena Machkasova elenam@morris.umn.edu
Last modified: 3/6/08
-->
<?php
$credits = $_GET["credits"];
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>
Review question 1
</title>
</head>
<body>
<h2>Does this work correctly?</h2>
<p>
<?php
if ($credits < 30) {
  print "You are a freshman<br />\n";
} else if ($credits < 90) {
  print "You are a junior<br />\n"; 
} else if ($credits < 60) {
  print "You are a sophomore<br />\n";
} else {
  print "You are a senior<br />\n";
}
?>
</p>
</body>
</html>
http://rynite.morris.umn.edu/~elenam/1101_spring08/review1/conditionals.php?credits=15

What will be printed by this loop?


<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Loops review question
Author: Elena Machkasova elenam@morris.umn.edu
Last modified: 3/6/08
-->
<?php
$n = $_GET["input"];
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>
Review question 2
</title>
</head>
<body>
<h2>What will be printed?</h2>
<p>
<?php
$m = 2;
for ($i = 0; $i < $n; $i++) {
  print "m = $m<br />\n";
  $m = $m * $m;
}
?>
</p>
</body>
</html>
http://rynite.morris.umn.edu/~elenam/1101_spring08/review1/loop_question.php?input=3

UMM CSci 1101