Features Flashcards
How can you use PHP to send an “Authentication Required” box to the browser?
Use the header() function. The username, password, and authentication type will be placed in PHP_AUTH_USER, PHP_AUTH_PW, and AUTH_TYPE, in the $_SERVER AND $HTTP_SERVER_VARS arrays. Both basic and digest authentication methods are supported.
When using PHP to do browser-based authentication, what do you need to do to guarantee maximum compatibility?
The keyword “Basic” should be written with an uppercase “B”, the realm string must be enclosed in double quotes (not single), and exactly one space should precede the 401 code in the HTTP/1.0 401 header line. For buggy IE browsers, send the WWW-Authenticate header before the HTTP/4.01 header.
How does PHP determine if external authentication is in effect?
It uses the presence of the AuthType directive.
How can you set cookies?
With setcookie() or setrawcookie().
When must setcookie() be called?
Before any output is sent to the browser (the same limitation that header() has). You can use the output buffering functions to delay the script output until you have decided whether or not to set any cookies or send any headers.
Where are client cookies placed?
They are automatically included into a $_COOKIE auto-global array if variables_order contains “C”.
How can you assign multiple values to a single cookie?
Just add [] to the cookie name.
What are XForms?
They’re a variation on traditional webforms which allow them to be used on a wider variety of platforms. The form details are sent as XML formatted data.
With XForms, where is the browser-generated XML document stored?
$HTTP_RAW_POST_DATA
When using XForms, how can you get your data loaded into the traditional $_POST variable?
Instruct the client browser to send it as application/x-www-form-urlencoded by changing the method attribute to urlencoded-post.
From what can PHP receive file uploads?
Any RFC-1867 compliant browser.
In a form, where can the MAX_FILE_SIZE hidden field be placed?
It must precede the file input field.
How reliable is the MAX_FILE_SIZE field?
Not at all. It’s simply a convenience feature to notify the user prior to attempting to transfer a large file. It’s easy to fool on the browser side.
What attribute do you need in a form for uploading files?
enctype=”multipart/form-data”
Where are uploaded files placed?
In the server’s default temporary directory, unless another location has been given with the upload_tmp_dir directive in php.ini.
Can you set upload_tmp_dir with putenv()?
No; it won’t work.