Zend PHP 5 Certification: Exam Question Assistance (06 May 2010)
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). :-)
PHP Code:
<?php
function redirect($url) {
// Check to make sure we haven't already sent
// the header:
1. Of the 3 functions listed in the answer, only headers_list() is in the manual. But it does not answer the question posed by the code comment, which would be better addressed by the headers_sent() function, in my opinion.
2. I would think only the first URL would, as the others would not actually be well-formed URLs with a fixable query string.
3. I know that the preg_*() (PCRE) functions are preferred over the ereg_*() functions (which are deprecated), while strregex() is not defined and the other two functions are not really regexp functions (though strtok() is somewhat similar and might be preferred in certain specific circumstances where you might consider using a regexp function).
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks