adding file for working through looping control structures
This commit is contained in:
parent
ea522b13e7
commit
b39eaef485
34
docroot/html/loops.php
Normal file
34
docroot/html/loops.php
Normal file
@ -0,0 +1,34 @@
|
||||
<pre>
|
||||
<?php
|
||||
|
||||
$c = 0;
|
||||
|
||||
while ($c < 5) {
|
||||
print $c++ . "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
</pre>
|
||||
|
||||
|
||||
<pre>
|
||||
<?php
|
||||
|
||||
$myname = "Fred";
|
||||
$i = 0;
|
||||
|
||||
while ($myname != "Rumpelstiltskin") {
|
||||
print $i++ . ": ";
|
||||
|
||||
if ($myname == "Fred") {
|
||||
$myname = "Leslie";
|
||||
} else {
|
||||
$myname = "Rumpelstiltskin";
|
||||
}
|
||||
print "$myname\n";
|
||||
}
|
||||
|
||||
print "How did you know?\n";
|
||||
|
||||
?>
|
||||
</pre>
|
Loading…
Reference in New Issue
Block a user