diff options
author | Kyle Kaminski <kyle@kkaminsk.com> | 2013-06-16 03:25:26 -0500 |
---|---|---|
committer | Kyle Kaminski <kyle@kkaminsk.com> | 2013-06-16 03:25:26 -0500 |
commit | 1bad4fc00814e2c03ecadaa7faf93c6372f5bd30 (patch) | |
tree | 88104590feefcb804f5fa0ca57ee1a6c76cbf0a7 /datatypes.php | |
download | phpsandbox-1bad4fc00814e2c03ecadaa7faf93c6372f5bd30.tar.gz phpsandbox-1bad4fc00814e2c03ecadaa7faf93c6372f5bd30.tar.bz2 phpsandbox-1bad4fc00814e2c03ecadaa7faf93c6372f5bd30.zip |
initial commit
Diffstat (limited to 'datatypes.php')
-rw-r--r-- | datatypes.php | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/datatypes.php b/datatypes.php new file mode 100644 index 0000000..53e8678 --- /dev/null +++ b/datatypes.php @@ -0,0 +1,70 @@ +<!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 />";
+
+ $hellomsg = "Hello Kyle, world is good.<br />";
+ /* note: single quotes would not do in place variable substitution */
+ echo "{$hellomsg}"; /* weird, opposite of bash */
+
+ $myarray = array(12, 21, 33, 99, 33, "fox" /* hmm this is nice */, array("bro", "brotato"));
+ echo "2nd item in our array is " . $myarray[1] . " " . $myarray[6][1] . ".<br /><br />";
+
+ /* key-value pairs, i like them, dejavu Lua! */
+ $keyval = array("name" => "bro", "status" => "amused", "location" => "/dev/null");
+ echo "$keyval[name] is $keyval[status]";
+
+ echo "</p><pre>";
+ print_r($keyval);
+ echo "</pre><br /><p>";
+
+ /* array into a string? seems heck useful */
+ $str_from_arr = implode(" ~ ", $keyval); /* 1st param = glue */
+ echo "the imploded array is: {$str_from_arr}";
+?>
+
+<!-- just easier to type in html :p -->
+<br />
+Is Pi set?
+ <?php
+ if (isset($pi)) /* will catch undefined variables */
+ echo "Yes" . "<br />";
+ else
+ echo "No" . "<br />";
+
+ /* how to escape? */
+ $var1 = "\"brotato escaped\"";
+ echo "escaped: " . $var1 . ", ha it is just like C!". "<br />";
+
+ unset($pi); /* why not just set it to null? we can set it to 0, "0"! and null */
+ if (empty($pi))
+ echo "Pi has been unset.<br />";
+ ?>
+<br />
+Typecasting, <b>php is very clever!</b><br />
+ <?php
+ $pi = 3.14159;
+ $piphi = $pi + "1.618 i love this number";
+ echo "piphi is of type " . gettype($piphi) . " and equals to {$piphi}.<br />";
+ settype($piphi, "string"); /* or just typecast, (string) in front ? */
+
+ /* constants */
+ define("PI_VAL", 3.14159);
+ ?>
+</p>
+</body>
+</html>
+
|