I am interviewing for new code monkeys. The test we currently give code monkeys to fill in is rather old and dull. Here is one of the current questions:
Code: Select all
What is the output of the following code?
<?
function r($p) {
if ($p==1) {
return 1;
} else {
return $p*r($p-1);
}
}
echo r(5);
?>Code: Select all
There are no errors when the following code is executed but is does not function as expected. What is missing?
$user = array( 1 => array('name' => 'john', 'email' => 'john@tpoll.com'),
2 => array('name' => 'barry', 'email' => 'barry@tpoll.com'),
3 => array('name' => 'bob', 'email' => 'bob@tpoll.com'));
//LIST EMAILS
while (list($id, $user_array) = each($user)) {
print $user_array['email']."<br>";
}
//LIST NAMES
while (list($id, $user_array) = each($user)) {
print $user_array['name']."<br>";
}So, if any of you can thing of a hard question about PHP (specifically OO-type stuff) (or MySQL, if you are bored) that can be answered without having to write an essay, I would be interested in seeing them.
Better include the answers, too