Академический Документы
Профессиональный Документы
Культура Документы
Question 1
What is the output of the following code?
$g = range(5,8);
$h = array("a", "b", "c", "e");
for($i = 0; $i < count($g); $i++) {
foreach ($h as $j) {
echo $i.$j;
break;
}
}
0a1a2a3a
0a0b0c0e1a1b1c1e2a2b2c2e3a3b3c3e
0a0b0c0e
5a6a7a8a
_______________________________________________________________________________________________________________
1/6
Generated with: ZCE Chrome Extension
Question 2
What is the output of the following PHP script?
$foo = 'bar';
echo '$foo\'' . "$foo\'";
$foo'bar\'
bar'$foo\'
$foo'bar
$foobar
_______________________________________________________________________________________________________________
2/6
Generated with: ZCE Chrome Extension
Question 3
Using nl2br() is a handy way to format plain-text for output in a HTML document. What is the
output of the following PHP script?
$str = nl2br("foo\nbar");
# nl2br doesn't remove the \n
$str = str_replace("\n", "", $str);
echo nl2br($str);
foo bar
null
foobar
foo<br />bar
_______________________________________________________________________________________________________________
3/6
Generated with: ZCE Chrome Extension
Question 4
How do you declare a function to accept a variable (unknown) number of arguments in PHP 7?
function foo(...$parms) {}
_______________________________________________________________________________________________________________
4/6
Generated with: ZCE Chrome Extension
Question 5
What is the output of the following PHP script?
$values = array(37, 5, "09");
sort($values, SORT_STRING);
foreach ($values as $v) {
echo $v;
}
09375
09537
53709
50937
_______________________________________________________________________________________________________________
5/6
Generated with: ZCE Chrome Extension
Answers
Answer for Question 1
A
_______________________________________________________________________________________________________________
6/6