Therefore, the outcome is the following:
1
2
3
Static scoping is particularly useful for recursive functions. Recursive functions are
a powerful programming concept in which a function repeatedly calls itself until a
particular condition is met. Recursive functions are covered in detail in Chapter 4.
PHP??™s Superglobal Variables
PHP offers a number of useful predefined variables that are accessible from anywhere
within the executing script and provide you with a substantial amount of environment-
specific information. You can sift through these variables to retrieve details
about the current user session, the user??™s operating environment, the local operating
environment, and more. PHP creates some of the variables, while the availability and
value of many of the other variables are specific to the operating system and Web
server. Therefore, rather than attempt to assemble a comprehensive list of all
possible predefined variables and their possible values, the following code will
output all predefined variables pertinent to any given Web server and the script??™s
execution environment:
foreach ($_SERVER as $var => $value) {
echo "$var => $value
";
}
CHAPTER 3 ?– PHP BASICS 81
This returns a list of variables similar to the following. Take a moment to peruse
the listing produced by this code as executed on a Windows server. You??™ll see some of
these variables again in the examples that follow:
HTTP_HOST => localhost:81
HTTP_USER_AGENT => Mozilla/5.
Pages:
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165