Key Words:function, method, procedure, form control, input, id,
onchange, event handler, function call, function definition,
function head, formal parameter, function body, variable, variable declaration,
assignment operator, assign, value,
text, string of characters, +, string concatenation, string.
See Wikipedia (http://en.wikipedia.org/) for a detailed
description of the key words.
You are required to have completed the objectives in theViking Lab before doing this lab.
Remember to use the online resources! When you encounter a new HTML element, look at W3Schools XHTML tutorial and W3C's XHTML and HTML recommendations. When you encounter a PHP function or want to find what you can do with an HTML element in your PHP code, look at W3Schools PHP tutorial. You do not need to understand everything in their tutorials, but you should at least know where to find help.
The goal of this section of the lab is to practice writing if/else statements.
count in the
HTML file. Print the variable to the screen and view the results.
<?php
$count = 1;
print('The count is: '. $count);
?>
<?php
$count = 1;
$ready = false;
if ($count == 0) {
print("I'm not ready!<br />");
} else {
$ready = true;
$count = $count-1;
}
echo("Ready: " . $ready . ", Count: " . $count ."<br />");
?>
count to 0. Reload the page.
if (isset($_GET['count'])
$count = $_GET['count'];
} else {
$count = 0;
}
Next add the input field to the HTML document.
<form action="<?php $_SERVER['PHP_SELF']" method="get"> Enter a number: <input id="count" type="text" /> <input type="submit" value="Submit" /> </form>
if statement so that when the count is greater than 10,
ready will be false.The goal of this section of the lab is to practice writing iteration statements and become familiar with how the for-statement works. We will also place images, which should be helpful on Project 2.
value in your document. Next initialize
and assign the variable i.
<?php
$value = 1;
for ($i=0; i<$value; $i++) {
echo "Print this text<br />";
}
?>
Declare an iteration variable (most programmers will pick i and that is what the examples assume). Write a loop that iterates 5 times, repeating the statement:
print("The iteration variable has the value " . $i . "<br />");
If the loop’s initialization sets i to 0 and limits the iteration to numbers less than 5 and increments by 1 each time, then the result should be
print("<img src='star.jpg' />< br />");
The result should look like the following
