I have just sat, and passed, another mock exam for the Zend PHP certification. The following questions came up in the test and I wondered if anyone would be able to help me out in obtaining the answers and the reasons (if possible). 🙂
[code=php]
<?php
function redirect($url) {
// Check to make sure we haven’t already sent
// the header:
if(???????) {
header(“Location: $url”);
}
}
?>
What conditional should replace the ????? above?
Answers:
[LIST][*]
!in_array(“Location: $url”, headers_list())
!header_exists(“Location: $url”)
!header_location($url)
$_SERVER[‘HTTP_LOCATION’] != $url
[code=php]
<?php
header(“Location: {$_GET[‘url’]}”);
?>
Which of the following values of $_GET[‘url’] would cause session fixation?
Answers:
[LIST][*]
Session Fixation is not possible with this code snippet
[url]http://www.zend.com/?PHPSESSID=123
PHPSESSID%611243
Set-Cookie%3A+PHPSESSID%611234
http%3A%2F%2Fwww.zend.com%2F%0D%0ASetCookie%3A+PHPSESSID%611234
=========================================================
If regular expressions must be used, in general which type of regular expression functions available to PHP is preferred for performance reasons?
[LIST][*]
strtok() using regular expressions
preg_* regular expression functions
parse_str() using regular expressions
strregex* regular expression functions
ereg* regular expression functions
=========================================================
Many thanks,
Picco