Both are introduced in this section.
header()
The header() function sends a raw HTTP header to the browser. The string parameter
specifies the header information sent to the browser. Its prototype follows:
void header(string string [, boolean replace [, int http_response_code]])
The optional replace parameter determines whether this information should
replace or accompany a previously sent header. Finally, the optional http_response_
code parameter defines a specific response code that will accompany the header
information. Note that you can include this code in the string, as will soon be demonstrated.
Applied to user authentication, this function is useful for sending the WWW
authentication header to the browser, causing the pop-up authentication prompt to
be displayed. It is also useful for sending the 401 header message to the user, if incorrect
authentication credentials are submitted. An example follows:
CHAPTER 14 ?– AUTHENTICATING YOUR USERS 369
header('WWW-Authenticate: Basic Realm="Book Projects"');
header("HTTP/1.1 401 Unauthorized");
?>
Note that unless output buffering is enabled, these commands must be executed
before any output is returned. Neglecting this rule will result in a server error,
because of the violation of the HTTP specification.
isset()
The isset() function determines whether a variable has been assigned a value. Its prototype
follows:
boolean isset(mixed var [, mixed var [,.
Pages:
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446