more looping stuff and playing with colors for Stephen, generalized header bits a touch

cat-town
Dan Buch 14 years ago
parent 3970fead8f
commit 9dab7bf8d7

@ -0,0 +1,35 @@
<?php
function mkheader($title, $bgcolor) {
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $title; ?></title>
<style type='text/css'>
/*<![CDATA[*/
body {
color: #222;
background-color: #eee;
font-family: monospace;
}
pre {
border: 1px dashed #777;
color: #000;
background-color: <?php echo $bgcolor ?>;
padding: 5px;
margin: 10px;
}
/*]]>*/
</style>
</head>
<?php
}
?>

@ -1,22 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<title>looping!</title>
<style type="text/css">
/*<![CDATA[*/
pre {
border: 1px dashed #777;
color: #222;
background: #fefefe;
padding: 5px;
margin: 10px;
}
<?php
require_once("_head.php");
$BGCOLOR_CHOICES = array(
'pink',
'purple',
'blue',
'red',
'green',
'gray',
'white',
'orange'
);
$bgcolor = $_GET['bgcolor'];
if (! $bgcolor) {
$bgcolor = $BGCOLOR_CHOICES[array_rand($BGCOLOR_CHOICES, 1)];
}
mkheader("looping!", $bgcolor);
?>
/*]]>*/
</style>
</head>
<body>
<p>Using &lt;pre&gt; bgcolor = <?php echo $bgcolor; ?></p>
<!-- ======================================================= -->
<pre><?php
$c = 0;
@ -28,6 +40,7 @@
?></pre>
<!-- ======================================================= -->
<pre><?php
$myname = "Fred";
@ -49,6 +62,7 @@
?></pre>
<!-- ======================================================= -->
<pre><?php
$c = 6;
@ -59,6 +73,7 @@
?></pre>
<!-- ======================================================= -->
<pre><?php
for ($i = 0; $i < 5; $i++) {
@ -68,6 +83,7 @@
?></pre>
<!-- ======================================================= -->
<pre><?php
$menu = array(
@ -88,5 +104,26 @@
?></pre>
<!-- ======================================================= -->
<pre><?php
$array = array(
"1st" => "My House",
"2nd" => "My Car",
"3rd" => "My Lab"
);
foreach ($array as $key => $value) {
if ($value == "My Lab") {
$array[$key] = $value = "My Laboratory";
}
print "$key holds the value $value \n";
}
?></pre>
</body>
</html>

Loading…
Cancel
Save