Question 1: What will this output
<?php
$a = false;
$b = true;
$c = false;
if ($a ? $b : $c) {
echo "false";
} else {
echo "true";
}
?>
Correct answer: trueExplanation: If $a is true, then $b will be evaluated; otherwise (as is the case here) $c will be evaluated. As $c is false, the conditional evaluates as false, and the script (confusingly) prints true.
Correct answer: preg_replace("/like/", "hate", "I like Regular Expressions")
Explanation: The search is a regular expression and it has slashes around it, the replace isn't, so it doesn't have any slashes.
Correct answer: GD library
Explanation: http://www.boutell.com/gd/
Correct answer: Both of them
Explanation: imap_mail, mail
Correct answer: It requires short tags and this is not compatible with XML
Explanation: If you have short_open_tag On then this XML <?xml version="1.0" encoding="utf-8"?> (for example) will be parsed by the PHP engine, causing both a PHP and a XML parsing error.
Correct answer: That won't hide any error 'coz it's not the correct code
Explanation: I would have said 'Good idea, increases security', but wait a minute... the correct syntax is php_flag display_errors Off ...
Correct answer: ..\...\...
Explanation: Any character (twice) followed by a period followed by any character (twice) followed by ...
Correct answer: Method
Explanation: It is a function, but since it's in a class we call it a method.
Correct answer: Ends execution of the current for, foreach, while, do-while or switch structure
Explanation: Yup. If you were tempted to say 'moves on to the next iteration', that's the continue statement.
$4bears = $bears->getFirst4();Correct answer: No
Explanation: A variable name can't start with a number. Don't ask me why not, I don't see any reason why it shouldn't; it's probably some carry over from C.
Correct answer: Rasmus Lerdorf
Explanation: The history is a bit more complicated than that, so here it is if you want to read it.
<?php
$dog = "Dogzilla";
$dragon = &$dog;
$dragon = "Dragonzilla";
echo $dog." ";
echo $dragon;
?>Correct answer: Dragonzilla Dragonzilla
Explanation: $dragon is really $dog, it just has a different name.
Correct answer: You can never be 100% sure if a page was created by PHP
Explanation: A PHP page might be missing the X-Powered-By: PHP header and have an extesion different from .php. In addition, you can output that header and use the extension .php when programming with any other language, just to confuse potential hackers.
Correct answer: Yes
Explanation: Yup, it's a multidimensional array.
Correct answer: DESCRIBE tblQuiz
Explanation: The others will just produce an error.
Correct answer: SELECT COUNT(*) FROM tblQuiz
Explanation: This is some very basic SQL syntax, I hope you got it right.
Correct answer: perform authentication without unnecessarily exposing the access credentials
Explanation: md5 returns an unique hash string for the string you pass it; if you have only the hash it's practically impossible to find the string that produces it.
Correct answer: Yes
Explanation: Duuh! Ever heard of joins?!
Correct answer: A dolphin
Explanation: You'll see the dolphin on the My SQL site.
<?php
function my_func($variable)
{
return (is_numeric($variable) && $variable % 2 == 0);
}
?>Correct answer: tests whether $variable is an even number
Explanation: It returns true if $variable is divisible by 2.
Correct answer: In both PHP and MySQL you have a function called sqrt
Explanation: The Manual.
+--------------+--------------+
| Field | Type |
+--------------+--------------+
| userName | varchar(20) |
| userScore | tinyint(3) |
| userComments | varchar(255) |
| quizName | varchar(20) |
+--------------+--------------+Correct answer: select quizName, avg(userScore) from tblQuiz group by quizName;
Explanation: The third option would have been correct if instead of userScore / count(userScore) it had sum(userScore) / count(userScore).
+--------------+--------------+
| Field | Type |
+--------------+--------------+
| userName | varchar(20) |
| userEmail | varchar(20) |
| userScore | tinyint(3) |
| userComments | varchar(255) |
| quizName | varchar(20) |
| quizType | varchar(20) |
| quizUrl | varchar(20) |
+--------------+--------------+Correct answer: it's not normalized, and that's NOT OK
Explanation: The quiz data (name, type, url) should be moved in a new table because it repeats itself on many rows. The table that stores results should be linked to this new table by a foreign key.
Correct answer: OO Analysis, OO Design, OO Programming
Explanation: First Analysis, then Design, then Programming.
class T
{
public $m = "a";
function T()
{
$this->m = "b";
}
}
$t = new T();
$p = $t->m;
$p = "c";
echo $t->m;
Correct answer: b
Explanation: $p = "c"; does not modify the object member.






0 comments:
Post a Comment