From 1bad4fc00814e2c03ecadaa7faf93c6372f5bd30 Mon Sep 17 00:00:00 2001 From: Kyle Kaminski Date: Sun, 16 Jun 2013 03:25:26 -0500 Subject: initial commit --- scope.php | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 scope.php (limited to 'scope.php') diff --git a/scope.php b/scope.php new file mode 100644 index 0000000..fc25ce4 --- /dev/null +++ b/scope.php @@ -0,0 +1,50 @@ + + + +Hacker's Corner + + + +\n"; + } + + function test2() + { + global $var; /* extern */ + $var = 2; /* now we actually change the global */ + echo $var . "
\n"; + } + + function test3() + { + /* local var with ability to retain value in multiple calls */ + static $var = 0; + + echo "test3 var: {$var}
\n"; + $var++; + } + + test1(); + echo $var . "

\n"; + + test2(); + echo $var . "
\n"; + + test3(); + test3(); + test3(); + test3(); + test3(); + echo $var; +?> + + + -- cgit v1.2.3