PHP automatically creates variables for all the data it receives in an HTTP request. This can include GET data, POST data, cookie data, and environment variables. The variables are either in PHP's global symbol table or in one of a number of superglobal arrays, depending on the value of the register_globals setting in your php.ini file.
Beginning with PHP 4.2.0, the default setting for register_globals is off. With register_globals off, all the various variables that are usually available directly in the global symbol table are now available via individual superglobal arrays. There is a limited set of superglobals and they cannot be created from a user-level script. The superglobal array to use depends on the source of the variable. Here is the list:
<?php foreach($_SERVER as $key=>$val) { echo '$_SERVER['.$key."] = $val<br>\n"; } ?>
<input name="userfile" type="file">
the $_FILES array will look something like this:
$_FILES['userfile']['name'] => photo.png $_FILES['userfile']['type'] => image/png $_FILES['userfile']['tmp_name'] => /tmp/phpo3kdGt $_FILES['userfile']['error'] => 0 $_FILES['userfile']['size'] => 158918
Note that the 'error' field is new for PHP 4.2.0 and the values are: 0 (no error, file was uploaded); 1 (the uploaded file exceeds the upload_max_filesize directive in php.ini); 2 (the uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form); 3 (the actual number of bytes uploaded was less than the specified upload file size); and 4 (no file was uploaded).
Copyright © 2003 O'Reilly & Associates. All rights reserved.