blob: 8e608e2378279fabf7ab47334fd915a3c05a6b4d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hacker's Corner</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Please Don't Fear!</h1>
<b>Sandbox:</b> Let's Roll!<br />
<p>
<?php
error_reporting(E_ALL | E_STRICT);
ini_set("display_errors", 1);
$pi = 3.14159;
echo "Pi = " . $pi . "<br />";
switch ($pi)
{
case 1.618:
break;
case 3.14159:
echo "cought it.<br />";
break;
default:
echo "how could this happen?<br />";
break;
}
/* while and for are straightforward, foreach is interesting, it allows us
* to loop through assosiative arrays, aka key-value pair */
$myarr = array("world" => "evil", "bro" => "ski", "he" => "is good man");
foreach ($myarr as $value)
echo "the value is \"{$value}\"<br />";
echo "<br />";
foreach ($myarr as $key => $value) /* fucking weird */
echo "at {$key} the value is \"{$value}\"<br />";
echo '<br />$myarr points to "' . current($myarr) . "\".<br />";
reset($myarr);
next($myarr);
echo '$myarr now points to "' . current($myarr) . "\".<br />";
/* incrementing pointer */
while ($str = current($myarr))
{
echo $str . ", ";
next($myarr);
}
?>
</p>
</body>
</html>
|