0001 |
Consider the following script: |
<html>
<head>
<title>PHP</title>
</head>
<body>
<?php echo 'This is some sample text'; ?>
</body>
</html> |
Which of the following tags is used in the php script? |
0 |
0 |
1 |
0002 |
Which of the following equivalence operations evaluates to true if the two operands are not of the same data type or do not have the same value? |
|
|
0 |
0 |
1 |
0003 |
Consider the following code: |
$a = 5;
$b = 12;
$c = 10;
$d = 7;
$e = ($a * $b) + $c * $d / $a;
print($e); |
What will be the output of the above code? |
0 |
0 |
1 |
0004 |
What will be the output when you try to run the script below? |
$b = false;
if ($b = true) {
print("true");
} else {
print("false");
} |
|
0 |
0 |
1 |
0005 |
Which of the following options is/are correct regarding variable scopes in PHP? |
|
|
0 |
0 |
1 |
0006 |
You run the following PHP script: |
for($x = 1; $x <= 2; $x++) {
for($y = 1; $y <= 3; $y++) {
if ($x == $y) continue;
print("x = $x y = $y");
}
}
|
What will be the output? Each correct answer represents a complete solution. Choose all that apply. |
0 |
0 |
1 |
0007 |
What is the result when the following PHP code involving a boolean cast is executed? |
var_dump( (bool) 5.8 );
|
|
0 |
0 |
1 |
0008 |
What will be the output of the following PHP script: |
function modifyArray(&$array) {
foreach ($array as &$value) {
$value = $value + 2;
}
$value = $value + 3;
}
$array = array(1, 2, 3);
modifyArray($array);
print_r($array); |
|
0 |
0 |
1 |
0009 |
Which of the below provided options is correct regarding the below code? |
$a = array(1, 2, 3);
$b = array(1=> 2, 2 => 3, 0 => 1);
$c = array('a' => 1,'b' => 2,'c' => 3);
var_dump($a == $b);
var_dump($a === $b);
var_dump($a == $c); |
|
0 |
0 |
1 |
0010 |
Which one of the following four logical operators of PHP is not binary? |
|
|
0 |
0 |
1 |
0011 |
What does the following function do, when passed two integer values for $p and $q? |
function magic($p, $q) {
return ($q == 0) ? $p : magic($q, $p % $q);
} |
|
0 |
0 |
1 |
0012 |
Consider the following script: |
<?= strtotime("january 1, 1901"); ?>
|
What will be the output of the above PHP script if the older versions of glibc are present in the operating system? |
0 |
0 |
1 |
0013 |
Consider the following script: |
<?= date("M-d-Y", mktime(0, 0, 0, 12, 32, 1995)); |
What will be the output of the above script? |
0 |
0 |
1 |
0014 |
Mark works as a Web Application Developer for Blue Solutions Inc. He writes the following code: |
$x = 25;
while($x < 10) {
$x--;
}
print ($x); |
What will be the output when Mark tries to compile and execute the code? |
0 |
0 |
1 |
0015 |
What does the following code snippet do? |
$a = `ls -l`; |
|
0 |
0 |
1 |
0016 |
John works as a Website Developer for PHPWEB Inc. He is using a Windows operating system and is also working on PHP engine 7.1. He develops the following script: |
<?= date("M-d-Y", mktime(0, 0, 0, 12, 32, 1965)); |
What will be the output of the above PHP script? |
0 |
0 |
1 |
0017 |
Which of the following types of errors halts the execution of a script and cannot be trapped? |
|
|
0 |
0 |
1 |
0018 |
Which of the following features are Undeprecated in PHP 5.3? |
|
|
0 |
0 |
1 |
0019 |
Consider the following PHP script: |
<?= (int) ((0.1 + 0.7) * 10); ?> |
What will be the output of the PHP script? |
0 |
0 |
1 |
0020 |
Which of the following statements explains the difference between print() and echo()? |
|
|
0 |
0 |
1 |
0021 |
What is the output of the following PHP code? |
define('FOO', 10);
$array = array(10 => FOO,"FOO" => 20);
print $array[$array[FOO]] * $array["FOO"]; |
|
0 |
0 |
1 |
0022 |
Mark works as a Web Developer for Unicorn Inc. He develops an application in PHP using the following code: |
switch(1) {
case 1: print("Book Details");
case 2: print("Book Author");
default: print("Missing Book");
} |
What will be the output of the script? |
0 |
0 |
1 |
0023 |
Fred works as a Web developer in Fastech Inc. He writes the following script: |
$s = 2;
switch ($s) {
case 1:
print("Fred");
break;
case 2:
print("Fast");
case 3:
print("Tech");
default: print("default");
} |
What will be displayed as output when Fred attempts to run this PHP script? |
0 |
0 |
1 |
0024 |
Consider the following code: |
$x = 0;
$i;
for($i = 0; $i < 5; $i++) {
$x += $i;
}
print($x); |
What will be the value of x? |
0 |
0 |
1 |
0025 |
Consider the following code: |
$a = 20;
$b = 4;
$c = $a % $b;
print($c); |
What will be the value of the variable c? |
0 |
0 |
1 |
0026 |
Which of the following are the core extensions? Each correct answer represents a complete solution. Choose all that apply. |
|
|
0 |
0 |
1 |
0027 |
What is the result of the following code? |
$sentence = ['John', 'Doe', 'has', 'a', 'car'];
for ($i = 0; $i < count($sentence); $i++) {
echo (function() use ($sentence) {
return $sentence;
})()[$i][0];
} |
|
0 |
0 |
1 |
0028 |
You run the following PHP script: |
$x = 10;
$b = ++$x;
print($b); |
What will be the value of the variable $b? |
0 |
0 |
1 |
0029 |
You have been given a code snippet as follows: |
$somearray = ["hi", "this is a string", "this is a code"]; |
You want to iterate this array and modify the value of each of its elements.
Which of the following is the best possible to accomplish the task? |
0 |
0 |
1 |
0030 |
Which of the following code can be used to create case insensitive constant? |
|
|
0 |
0 |
1 |
0031 |
Which of the following data types are compound data types? |
|
|
0 |
0 |
1 |
0032 |
Consider the following PHP script: |
function b($a = 4) {
$a = $a / 2;
return $a;
}
$a = 10;
b($a);
echo $a; |
What will be the output? |
0 |
0 |
1 |
0033 |
You run the following PHP script: |
<?php echo 0x33, ' birds sit on ', 022, ' trees.'; |
What will be the output? |
0 |
0 |
1 |
0034 |
Consider the following code: |
$a;
for($a = 1; $a <= 100; $a++) {
if ($a == 50) {
continue;
}
print($a);
} |
What will be the output of the program? |
0 |
0 |
1 |
0035 |
In which of the following ways does the identity operator === compare two values? |
|
|
0 |
0 |
1 |
0036 |
Which of the following statements is/are FALSE regarding functions in PHP? |
|
|
0 |
0 |
1 |
0037 |
What is the output of the following code snippet? |
$a = 20;
function myfunction($b) {
$a = 30;
global $a, $c;
return $c = ($b + $a);
}
print myfunction(40) + $c; |
|
0 |
0 |
1 |
0038 |
Which of the following PHP variable names is not a valid variable name? |
|
|
0 |
0 |
1 |
0039 |
Which of the following is/are FALSE regarding OOP in PHP 5.3? |
|
|
0 |
0 |
1 |
0040 |
Assume that today is January 8th, 2013, 5:16:18 pm in MST time zone. |
<?php echo date('l \t\h\e jS'); |
|
0 |
0 |
1 |
0041 |
What is the value of $x in the following code snippet? |
$x = 123 == 0123; |
|
0 |
0 |
1 |
0042 |
Which of the following functions returns current Unix timestamp? |
|
|
0 |
0 |
1 |
0043 |
Which of the following files can be used to modify PHP configurations? |
|
|
0 |
0 |
1 |
0044 |
Which of the following PHP directives will you use to display all errors except notices? |
|
|
0 |
0 |
1 |
0045 |
You run the following PHP script: |
$a = 12;
$b = 11;
$a > $b ? print($a) : print($b); |
|
0 |
0 |
1 |
0046 |
Which of the following is used to set a constant? |
|
|
0 |
0 |
1 |
0047 |
What is the length of the hash generated by the crc32() crypto function? |
|
|
0 |
0 |
1 |
0048 |
Which of the following logical operators is an equivalence logical operator? |
|
|
0 |
0 |
1 |
0049 |
Which of the following options is NOT as valid tag for PHP script (PHP 5.3)? |
|
|
0 |
0 |
1 |
0050 |
Which of the following is a magic constant? |
|
|
0 |
0 |
1 |
0051 |
Which of the following options shows the correct IF statement format? |
|
|
0 |
0 |
1 |
0052 |
Which of the following operators has the highest precedence order? |
|
|
0 |
0 |
1 |
0053 |
Which of the following is related to APC (Alternative PHP Cache)? |
|
|
0 |
0 |
1 |
0054 |
Which of the following is NOT a strongly typed language? |
|
|
0 |
0 |
1 |
0055 |
Which of the following is NOT a valid PHP variable name? |
|
|
0 |
0 |
1 |
0056 |
You run the following PHP script: |
$a = 20 % -8;
echo $a; |
|
0 |
0 |
1 |
0057 |
You run the following PHP script: |
<?= (int) "1235Jason"; |
What will be the output? |
0 |
0 |
1 |
0058 |
You run the following script: |
<?php
function odd() {
for($i = 1; $i <= 50; $i = $i + 2) {
echo "$i";
}
}
echo "The last value of the variable \$i: $i"; |
What will be the output? |
0 |
0 |
1 |
0059 |
You run the following PHP script: |
<php echo (int) "Jason 1235";
|
What will be the output? |
0 |
0 |
1 |
0060 |
You run the following PHP script: |
$sale = 200;
$sale = $sale- + 1;
echo $sale; |
What will be the output? |
0 |
0 |
1 |
0061 |
Which of the following functions allows you to stack several error handlers on top of each other? |
|
|
0 |
0 |
1 |
0062 |
Consider the following code: |
$x = 10;
$y = 5;
$x += $y; |
What will be the value of $x and $y? |
0 |
0 |
1 |
0063 |
You run the following PHP script: |
$a = "b";
$b = 20;
echo $$a; |
What will be the output? |
0 |
0 |
1 |
0064 |
You run the following script: |
10 = $a;
echo $a; |
What will be the output? |
0 |
0 |
1 |
0065 |
You run the following PHP script: |
$num = -123test;
$newnum = abs($num);
print $newnum; |
What will be the output? |
0 |
0 |
1 |
0066 |
Which of the following will you use to iterate a PHP associative array? |
|
|
0 |
0 |
1 |
0067 |
You run the following script: |
$a = 6 - 10 % 4;
echo $a; |
What will be the output? |
0 |
0 |
1 |
0068 |
You run the following script: |
<?php
$a = 5 < 2;
echo (gettype($a)); |
What will be the output? |
0 |
0 |
1 |
0069 |
Consider the following PHP script: |
$a = [
'1' => "php",
"Hypertext",
"Preprocessor",
"widely used" => [
'general' => 'purpose',
'scripting' => 'language',
'that' => 'was',
'originally' => [
5 => 'designed',
9 => 'for',
'Web development',
4 => 'purpose'
]
]
];
//write code here |
What should you write here to print the value 'Web development'? |
0 |
0 |
1 |
0070 |
You run the following PHP script: |
$array1 = array ('a' => 20, 30, 35);
$array2 = array ('b' => 20, 35, 30);
$array = array_intersect_assoc($array1, $array2);
var_dump($array); |
What will be the output? |
0 |
0 |
1 |
0071 |
What will be the output of the PHP script given below? |
$array1 = array("orange", "banana", "apple", "raspberry");
$array2 = array(0 => "pineapple", 4 => "cherry");
$array3 = array(0 => "grape");
$array4 = array_replace($array1, $array2, $array3);
print_r($array4); |
|
0 |
0 |
1 |
0072 |
What will be the output of the following code snippet? |
$a = 1;
$b = 2;
$c = 0xAF;
$d = $b + $c;
$e = $d * $b;
$f = ($d + $e) % $a;
print($f + $e); |
|
0 |
0 |
1 |
0073 |
Consider the following PHP script: |
$base_array = array("red", "green", "yellow", "white");
$replacements_array = array(0 => "orange", 4 => "blue");
$result = array_replace($base_array, $replacements_array);
print_r($result); |
What will be the output of the script? |
0 |
0 |
1 |
0074 |
Consider the following code: |
$array = array("a1"=>'x', "a2"=>'e', "a3"=>'z');
asort($array);
foreach ($array as $keys => $values) {
print "$keys = $values";
} |
What will be the output? |
0 |
0 |
1 |
0075 |
What will be the output of the following PHP code? |
array_combine(array(1,2,3,6), array(4,5,6)); |
|
0 |
0 |
1 |
0076 |
Which of the following functions is used to insert a new element in the beginning of an array? |
|
|
0 |
0 |
1 |
0077 |
You have got the following array after applying some sorting operation: |
Array
(
[0] => book1.pdf
[1] => book11.pdf
[2] => book12.pdf
[3] => book2.pdf
) |
However, you wanted to sort the array in the following format: |
0 |
0 |
1 |
0078 |
You run the following code: |
$array = ['a1' => 'x', 'a2' => 'e', 'a3' => 'z'];
ksort($array);
foreach($array as $key => $value) {
print "$key = $value ";
} |
What will be the output? |
0 |
0 |
1 |
0079 |
What will be the output of the given PHP code? |
$name = array("d" => "Mark", "a" => "David", "b" => "Peter", "c" => "Martha");
$nameArrayObject = new ArrayObject($name);
$nameArrayObject->ksort();
foreach ($nameArrayObject as $key => $val) {
echo "$key = $val\n";
} |
|
0 |
0 |
1 |
0080 |
You run the following PHP script: |
$array1 = array("a", "b", "c", "d", "e", "f");
$array2 = array_slice($array1, -3);
foreach($array2 as $val) {
print "$val ";
} |
What will be the output? |
0 |
0 |
1 |
0081 |
What will be the output of the following code snippet? |
$array = array(1 => 'one', 3 => '10');
echo $array; |
|
0 |
0 |
1 |
0082 |
What will be the output of the following PHP code snippet? |
$array = array(1.1 => '1', 1.2 => '1');
echo count($array); |
|
0 |
0 |
1 |
0083 |
Which of the following is the correct naming convention of user defined functions? |
|
|
0 |
0 |
1 |
0084 |
Which of the following functions returns an array containing all the values of first array that are present in all the arguments? |
|
|
0 |
0 |
1 |
0085 |
Which of the following options about return statement is true? |
|
|
0 |
0 |
1 |
0086 |
Which of the following functions will you use to merge one or more arrays? |
|
|
0 |
0 |
1 |
0087 |
You want to create an anonymous function in the middle of a script that will return the square of a given number.
Which of the following PHP scripts can you use to accomplish the task? |
|
Each correct answer represents a complete solution. (Choose two) |
0 |
0 |
1 |
0088 |
You have been given the date format "yyyy-mm-dd". You want to put values in the $year, $month, and $day variables.
Which of the following PHP code snippets will you execute to accomplish this task? |
|
|
0 |
0 |
1 |
0089 |
Consider the following PHP script: |
$a = 5;
$b = 10;
function Mul() {
// ????
}
Mul();
print($b); |
What can you write instead of // ???? on line 4 to get the output 50? Each correct answer represents a complete solution. Choose all that apply. |
0 |
0 |
1 |
0090 |
Consider the following PHP script: |
$a = 5;
$b = 10;
function Mul() {
$GLOBALS['b'] = $GLOBALS['a'] * $GLOBALS['b'];
}
Mul();
print($b); |
What will be the output? |
0 |
0 |
1 |
0091 |
Which of the following methods compares array1 against array2 and returns the difference by checking array keys in addition? |
|
|
0 |
0 |
1 |
0092 |
Which of the following functions returns an array with all keys from input lowercased or uppercased? |
|
|
0 |
0 |
1 |
0093 |
Which of the following functions can be used to check whether a particular element exists in a given array or not? |
|
|
0 |
0 |
1 |
0094 |
What will be the output of the following code? |
function a(&$a = 19) {
$a .= 1;
}
$b = 6;
a($b);
echo $b++; |
|
0 |
0 |
1 |
0095 |
What will be the output of the following code snippet? |
$input = [4, "4", "3", 4, 3, "3", 3, 3, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7];
echo count(array_unique($input)); |
|
0 |
0 |
1 |
0096 |
You run the following script: |
$array1 = array ("a", "b", "c", "d", "e", "f");
$array2 = array_slice($array1, 2, 2);
foreach ( $array2 as $val ) {
print "$val ";
} |
What will be the output? |
0 |
0 |
1 |
0097 |
Which of the following statements will return the second parameter passed to a function? |
|
|
0 |
0 |
1 |
0098 |
You have been given the following PHP script: |
$a = 'somevalue';
$array = ["a" => "One", "b" => "Two", "c" => "Three"];
// ????
echo "\$a = $a; \$b = $b; \$c = $c;"; |
What should you write at line number 3 to get the following output?
$a = One; $b =Two; $c = $Three; |
0 |
0 |
1 |
0099 |
You are running the following PHP script: |
$queue = array(1, 2);
array_unshift($queue, 0, 4);
print_r($queue); |
What will be the output? |
0 |
0 |
1 |
0100 |
Consider the following script: |
$a = array('a', 'b');
array_push($a, array(1, 2));
print_r($a); |
What will be the output? |
0 |
0 |
1 |
0101 |
Consider the following PHP script: |
$a = 5;
$b = 10;
function Mul() {
$a =0;
$b = $a * $b;
}
Mul();
print($b); |
What will be the output of the above script? |
0 |
0 |
1 |
0102 |
Which of the following methods is used to retain properties when accessed as a list? |
|
|
0 |
0 |
1 |
0103 |
What is the result of the following code? |
function foo() {
return array_sum(func_get_args());
}
$x = foo(1,2,3);
echo ($x ?? 'x'); |
|
0 |
0 |
1 |
0104 |
What will be the output of the following PHP script? |
$array = [
'a' => 'One',
'b' => 'Two',
'c' => [
'd' => 'Three',
'e' => 'Four'
]
];
function print_element($array) {
extract($array);
return $c['e'];
}
print print_element($array); |
|
0 |
0 |
1 |
0105 |
Which of the following methods fills an array with the value of the value parameter, using the values of the keys array as keys? |
|
|
0 |
0 |
1 |
0106 |
Which of the following operators will you use to check whether two variables contain the same instance of an object or not? |
|
|
0 |
0 |
1 |
0107 |
You have been given the following PHP code snippet: |
$array = array('1', '2', '3');
foreach($array as $key => $value) {
$value = 4;
}
print_r($array); |
What will be the output? |
0 |
0 |
1 |
0108 |
You passed an associative array to the sort() function. What will happen? |
|
|
0 |
0 |
1 |
0109 |
Consider the following PHP script: |
$var1 = ["foo", "bar", "hello", "world", "PHP", "nice"];
$var2 = ["foo", "bar", "hello", "PHP", "nice", "language"];
echo count(array_merge(array_diff($var1, $var2), array_diff($var2, $var1))); |
What will be the output of the script? |
0 |
0 |
1 |
0110 |
You have given the following PHP code: |
class Example {
public $public = '1';
private $prv = '2';
protected $prt = '3';
}
$arrayobj = new ArrayObject(new Example());
var_dump($arrayobj->count()); |
What will be the output? |
0 |
0 |
1 |
0111 |
Which of the following functions will you use to sort the values of an array object by preserving key values? |
|
|
0 |
0 |
1 |
0112 |
What will be the result of comparing the following two PHP arrays? |
$x = array(10,2,4);
$y = array(1 => 2, 0 => 10, 2 => 4);
var_dump($x == $y); |
|
0 |
0 |
1 |
0113 |
Which of the following keywords is used to prevent a method/class to be overridden by a subclass? |
|
|
0 |
0 |
1 |
0114 |
You run the following PHP script: |
class Test
{
function __call( $var1, $var2) {
$check = " '$var1' called\n";
$check.= print_r($var2, true);
return $check;
}
}
$item = new Test();
print $item->xxx( "John", "Maria", "Jason" ); |
What is the work of the __call() method in the above script? |
0 |
0 |
1 |
0115 |
Which of the following allows a programmer to set a string value for the object that will be used if the object is ever used as a string? |
|
|
0 |
0 |
1 |
0116 |
Which of the following variables are NOT supported by type hinting (PHP < 7)? Each correct answer represents a complete solution. Choose two. |
|
|
0 |
0 |
1 |
0117 |
Consider the following PHP code snippet: |
class A {
static $word = "hello";
static function hello() {
print static::$word;
}
}
class B extends A {
static $word = "bye";
}
B::hello(); |
What will be the output on running the above mentioned code snippet? |
0 |
0 |
1 |
0118 |
Which operator can be used to decide whether or not an object of a class is inheriting property from another class? |
|
|
0 |
0 |
1 |
0119 |
Which of the following access controls specifies that a feature can be accessed by any other class? |
|
|
0 |
0 |
1 |
0120 |
Which of the following are the uses of Reflection? Each correct answer represents a complete solution. Choose all that apply. |
|
|
0 |
0 |
1 |
0121 |
Which of the following is used to pass an object? |
|
|
0 |
0 |
1 |
0122 |
Which of the following error constants gives all errors and warnings, except the E_STRICT error level? |
|
|
0 |
0 |
1 |
0123 |
In which of the following situations will you use the set_exception_handler() function? |
|
|
0 |
0 |
1 |
0124 |
Which of the following statements correctly explains the use of instanceof and type hinting?
Each correct answer represents a complete solution (Choose three). |
|
|
0 |
0 |
1 |
0125 |
Which of the following methods is called when a user sets a value of an undeclared or undefined attribute of a class? |
|
|
0 |
0 |
1 |
0126 |
Which of the following options shows the correct format of fetching class variables using the $this variable? |
|
|
0 |
0 |
1 |
0127 |
What is the primary difference between a method declared as static and a normal method? |
|
|
0 |
0 |
1 |
0128 |
Which of the following streams is used to access the compressed data? |
|
|
0 |
0 |
1 |
0129 |
What is the output of the following code? |
class A {};
class B1 extends A {};
class_alias('A', 'B2');
$b1 = new B1; echo get_class($b1);
$b2 = new B2; echo get_class($b2); |
|
0 |
0 |
1 |
0130 |
You run the following PHP script: |
class number
{
public $a = 1;
protected $b = 2;
private $c = 3;
}
$numbers = new number();
foreach($numbers as $value) {
echo "$value ";
} |
What will be the output? |
0 |
0 |
1 |
0131 |
Maria creates an application using PHP script. The application contains certain classes. The class design requires that a particular member variable must be directly accessible to any subclass of this class only. What should Maria do to achieve this? |
|
|
0 |
0 |
1 |
0132 |
Which of the following statements is/are FALSE regarding closures in PHP 5.3? |
|
|
0 |
0 |
1 |
0133 |
Which of the following statements is/are FALSE regarding forward_static_call_array() function in PHP 5.3? |
|
|
0 |
0 |
1 |
0134 |
You want to save a client's session values in a database. Which of the following actions will you take to accomplish this task? |
|
|
0 |
0 |
1 |
0135 |
Assuming every method call below returns an instance of an object, how can the following be re-written in PHP5/7? |
$a = new MyClass();
$b = $a->getInstance();
$c = $b->doSomething(); |
|
0 |
0 |
1 |
0136 |
What is the output of the following code? |
interface foo {}
class_alias('foo', 'bar');
echo interface_exists('bar') ? 'yes' : 'no'; |
|
0 |
0 |
1 |
0137 |
Which of the following SPL Interfaces/classes extends the standard Iterator interface and enables the ability to retrieve a specific item from the internal data store? |
|
|
0 |
0 |
1 |
0138 |
Which of the following is triggered when inaccessible methods are triggered in an object context? |
|
|
0 |
0 |
1 |
0139 |
Which of the following functions will sort an array in ascending order by value, while preserving key associations? |
|
|
0 |
0 |
1 |
0140 |
What is the output of this code snippet? |
$a = [0.001 => 'b', .1 => 'c'];
print_r($a);
|
|
0 |
0 |
1 |
0141 |
Which of the following methods is called to directly echo or print() an object? |
|
|
0 |
0 |
1 |
0142 |
Fill in the blank with the appropriate word. The ____ operator lets a programmer inspect all of the ancestor classes of the object, as well as any interfaces. |
|
|
0 |
0 |
1 |
0143 |
Consider the following PHP code snippet: |
class Object
{
function Object($entity) {
$entity->name = "John";
}
}
class Entity
{
public $name = "Maria";
}
$entity = new Entity();
$obj = new Object($entity);
print $entity->name; |
What should be the output of this script (Ignore warning)? |
0 |
0 |
1 |
0144 |
Which of the following OOP`s design patterns is used to encapsulate a data source so that accessing data source components becomes hidden within the class that implements the pattern? |
|
|
0 |
0 |
1 |
0145 |
Fill in the blank with the appropriate method. The ____ method automatically calls whenever a user tries to instantiate a nonexistent class. |
|
|
0 |
0 |
1 |
0146 |
Consider the following PHP script: |
$a = 5;
$b = 4;
$c = ($a++ * ++$b);
echo $c; |
What will be the output? |
0 |
0 |
1 |
0147 |
Which of the following modes of the fopen() function opens a file in read and write mode and creates one if it does not exist? |
|
|
0 |
0 |
1 |
0148 |
Which of the following PHP functions will you use as a countermeasure against a cross-site scripting (XSS) attack? |
|
|
0 |
0 |
1 |
0149 |
Which of the following functions will you use as a countermeasure against a SQL injection attack? |
|
|
0 |
0 |
1 |
0150 |
Which function escapes all of the shell metacharacters and control operators within a string? |
|
|
0 |
0 |
1 |
0151 |
Which of the following data types cannot be directly manipulated by the client? |
|
|
0 |
0 |
1 |
0152 |
Which of the following directives can be used to improve the security while using the shared hosting environment? Each correct answer represents a complete solution. Choose all that apply. |
|
|
0 |
0 |
1 |
0153 |
John works as a professional ethical hacker. He has been assigned the project of testing the security of www.we-are-secure.com. On the We-are-secure login page, he enters ='or''=' as a username and successfully logs in to the user page of the Web site. To which of the following attacks is the We-are-secure login page vulnerable? |
|
|
0 |
0 |
1 |
0154 |
Which of the following is used to escape output and remove special characters to prevent from SQL injection attack, XSS attack, and other various types of attacks? |
|
|
0 |
0 |
1 |
0155 |
Which of the following functions is used to set whether to use the SOAP error handler? |
|
|
0 |
0 |
1 |
0156 |
Which of the following variables are saved in the session while using the HTTP authentication? Each correct answer represents a complete solution. Choose all that apply. |
|
|
0 |
0 |
1 |
0157 |
Which of the following is used to convert a scalar value into a single-quote delimited string that can be used safely as a single argument for a shell command? |
|
|
0 |
0 |
1 |
0158 |
Which of the following are the countermeasures of the remote code injection? Each correct answer represents a complete solution. Choose all that apply. |
|
|
0 |
0 |
1 |
0159 |
You want to stop showing PHP errors or to show only critical errors so that a malicious hacker cannot hack your Website. Which of the following PHP directive settings will you use to accomplish this task?
Each correct answer represents a part of the solution. Choose all that apply. |
|
|
0 |
0 |
1 |
0160 |
Which block algorithms does Mcrypt support? Each correct answer represents a complete solution. Choose all that apply. |
|
|
0 |
0 |
1 |
0161 |
Consider the following PHP script: |
<?= "Welcome, {$_POST['name']}."; |
What type of attack is possible with this PHP script? |
0 |
0 |
1 |
0162 |
Which of the following functions can be used as a countermeasure to a Shell Injection attack? Each correct answer represents a complete solution. Choose all that apply. |
|
|
0 |
0 |
1 |
0163 |
Consider a scenario in which a website allows users to upload pictures. What kind of security should be set to prevent attacks? |
|
|
0 |
0 |
1 |
0164 |
Which of the following functions is the best choice to retrieve the fingerprint of a string? |
|
|
0 |
0 |
1 |
0165 |
Which of the following are the limitations for the cross site request forgery (CSRF) attack? Each correct answer represents a complete solution. (Choose two) |
|
|
0 |
0 |
1 |
0166 |
You run the following PHP script: |
$name = mysqli_real_escape_string($_POST["name"]);
$password = mysqli_real_escape_string($_POST["password"]); |
What is the use of the mysqli_real_escape_string() function in the above script. Each correct answer represents a complete solution. Choose all that apply. |
0 |
0 |
1 |
0167 |
Which of the following directives can you use to prevent users from accessing private documents of the Web folders? Each correct answer represents a complete solution. (Choose three) |
|
|
0 |
0 |
1 |
0168 |
Which of the following functions will you use to get the following output of string "Hello world!"? |
|
"!dlrow olleH" |
0 |
0 |
1 |
0169 |
Which of the following settings will you use to secure your application? Each correct answer represents a complete solution. (Choose all that apply) |
|
|
0 |
0 |
1 |
0170 |
Which function is used to get a specific external variable by name and optionally filter it? |
|
|
0 |
0 |
1 |
0171 |
Which of the following functions wraps a string to a given number of characters? |
|
|
0 |
0 |
1 |
0172 |
Consider the PHP program (which includes a file specified by request): |
<?php
$color = 'blue';
if (isset( $_GET['COLOR'] ) )
$color = $_GET['COLOR'];
require( $color . '.php' );
?>
<form method="get">
<select name="COLOR">
<option value="red">red</option>
<option value="blue">blue</option>
</select>
<input type="submit">
</form> |
A malicious user injects the following command: |
0 |
0 |
1 |
0173 |
Which of the following functions can be used to translate characters or replace substrings? |
|
|
0 |
0 |
1 |
0174 |
Which of the following directives can be used to enable the byte cache performance? |
|
|
0 |
0 |
1 |
0175 |
What is the default timeout of a session cookie? |
|
|
0 |
0 |
1 |
0176 |
Which of the following protocols is used for mail transfer? |
|
|
0 |
0 |
1 |
0177 |
Which of the following directives should you delete to secure your applications? Each correct answer represents a complete solution. (Choose all that apply) |
|
|
0 |
0 |
1 |
0178 |
Fill in the blank with the appropriate PHP function. The _____ function is used to replace the current session id with the new session id, and to keep information of the current session. *Matching is case-insensitive. |
|
|
0 |
0 |
1 |
0179 |
Which of the following functions can you use to mitigate a command injection attack? Each correct answer represents a complete solution. (Choose two) |
|
|
0 |
0 |
1 |
0180 |
Which of the following is a PHP script vulnerability of the mail() function that can occur in Internet applications that are used to send email messages? |
|
|
0 |
0 |
1 |
0181 |
Which of the following is used to retrieve the namespaces used in an XML document from a SimpleXMLElement object? |
|
|
0 |
0 |
1 |
0182 |
Which of the following functions in SimpleXML can be used to return an iterator containing a list of all subnodes of the current node? |
|
|
0 |
0 |
1 |
0183 |
Which of the following are the methods used for producing web services? |
|
|
0 |
0 |
1 |
0184 |
What will be the output of the following PHP script? |
$dom = new DOMDocument();
$dom->load('book.xml');
$a = $dom->documentElement;
print_r($a); |
|
0 |
0 |
1 |
0185 |
Fill in the Blank with the appropriate method name. The ___ is used to import the SimpleXML objects for use with DOM. *Exact matching is required. |
|
|
0 |
0 |
1 |
0186 |
Which of the following is used to retrieve the root element from an XML file? |
|
|
0 |
0 |
1 |
0187 |
Which of the following is used to retrieve the name of an XML element from a SimpleXMLElement object? |
|
|
0 |
0 |
1 |
0188 |
Consider the following script: |
echo strtotime("january 1, 1901"); |
What will be the output of the above PHP script if older versions of glibc are present in the operating system? |
0 |
0 |
1 |
0189 |
Which of the following is used to retrieve the namespaces declared in an XML document from a SimpleXMLElement object? |
|
|
0 |
0 |
1 |
0190 |
Which of the following functions will output the current time in the 08:26 am format? Each correct answer represents a complete solution. Choose all that apply. |
|
|
0 |
0 |
1 |
0191 |
Which of the following protocols is normally used by Webservices? |
|
|
0 |
0 |
1 |
0192 |
Which of the following functions can you use to add data? Each correct answer represents a complete solution. Choose all that apply. |
|
|
0 |
0 |
1 |
0193 |
Which of the following functions sets up start and end element handlers? |
|
|
0 |
0 |
1 |
0194 |
Which function is used to set up start and end element handlers? |
|
|
0 |
0 |
1 |
0195 |
What code snippet will you use at line number four (4) in the code snippet given below? |
$client = new SoapClient("any.wsdl", array('exceptions' => 0));
$result = $client->SomeFunction();
if (??????) {
trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
} |
|
0 |
0 |
1 |
0196 |
All of the following are the pre-defined entities except for which one? |
|
|
0 |
0 |
1 |
0197 |
What will be the output of the following PHP script? |
$dom = new DOMDocument();
$dom->load('book.xml');
$a = $dom->documentElement;
print_r($a); |
|
0 |
0 |
1 |
0198 |
Which of the following is an XML protocol that implements the communication between one to another machine, including the publishing, finding, binding, and calling of a Webservice? |
|
|
0 |
0 |
1 |
0199 |
Which of the following was not a built-in terminology before PHP5? |
|
|
0 |
0 |
1 |
0200 |
Which of the following functions returns an XML string based on SimpleXML element? |
|
|
0 |
0 |
1 |
0201 |
Fill in the blank with the appropriate function name. The ____ function is used to return the current time measured in the number of seconds since the
Unix Epoch (January 1, 1970, 00:00:00 GMT). *Matching is case-insensitive. |
|
|
0 |
0 |
1 |
0202 |
You have given the following XML data in the tasks.XML file: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<tasklist>
<note>
<tasks>Validate data</tasks>
<details>String Validation</details>
</note>
<note>
<tasks>Secure data</tasks>
<details>Encryption</details>
</note>
</tasklist> |
Now, you run the following PHP script: |
0 |
0 |
1 |
0203 |
Which of the following functions will you use to create a new DomElement node?
Each correct answer represents a complete solution. Choose three. |
|
|
0 |
0 |
1 |
0204 |
Fill in the blank with the appropriate function name. The ___ function is used to decode a json encoded string/array. |
|
|
0 |
0 |
1 |
0205 |
Which of the following is a valid SOAP client call? |
|
|
0 |
0 |
1 |
0206 |
What will be the output of the following PHP code snippet?
echo strtotime("24:00"); |
|
|
0 |
0 |
1 |
0207 |
Consider the following XML file: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title> SimpleXML Example</title>
</head>
<body>
<h1>Please go <a href="http://www.ucertify.com">http://www.ucertify.com</a></h1>
</body>
</html> |
Which of the following statements will display the HREF attribute on the anchor tag if the SimpleXML object is $sxml? |
0 |
0 |
1 |
0208 |
Which of the following protocols is used to standardize the description of Web services so providers and requesters are speaking the same language? |
|
|
0 |
0 |
1 |
0209 |
All variables in PHP start with which symbol? |
|
|
0 |
0 |
1 |
0210 |
Which of the following retrieves the child nodes of a specified XML node? |
|
|
0 |
0 |
1 |
0211 |
Which of the following function is used to parse XML data into an array structure? |
|
|
0 |
0 |
1 |
0212 |
Fill in the blank with the appropriate PHP function. The __ function is used to return the sum of the values of every entry within an array. *Exact matching is required. |
|
|
0 |
0 |
1 |
0213 |
Which function is used to allow a parser to be used within an object? |
|
|
0 |
0 |
1 |
0214 |
All of the following are the advantages of Webservice except for which one? |
|
|
0 |
0 |
1 |
0215 |
Fill in the blank with the appropriate function name. The _____ function is used to encode a string/array into a json encoded string. |
|
|
0 |
0 |
1 |
0216 |
Which of the following is used to create an XML parser with namespace support? |
|
|
0 |
0 |
1 |
0217 |
Consider the following script: |
$string1 = "ab";
$string2 = "cd";
$string1 = $string1 . $string2;
$string3 = "abc";
$string1 .= $string3;
echo $string1; |
What will be the output of the above PHP script? |
0 |
0 |
1 |
0218 |
What are possible value of the following code, if $a and $b variable are defined in current scope script? |
echo ($a <=> $b);
|
|
0 |
0 |
1 |
0219 |
What will be the output of the following PHP code? |
$a = "hi,world";
$b = array_map("strtoupper", explode(",", $a));
foreach($b as $value) {
print "$value";
} |
|
0 |
0 |
1 |
0220 |
What will be the output of the following code? |
$s = '13149';
$s[$s[1]] = $s[1]+$s[3];
print_r($s); |
|
0 |
0 |
1 |
0221 |
You run the following PHP script: |
if ( preg_match("/[^a-z589]+/", "AB asdfg589nmGH", $array) ) {
print "<pre>\n";
print_r( $array );
print "</pre>\n";
} |
What will be the output? |
0 |
0 |
1 |
0222 |
Which of the following functions will you use to get the output from the string ? Each correct answer represents a complete solution. Choose all that apply. |
|
|
0 |
0 |
1 |
0223 |
You want to fetch the top level domain (com) from the email Which of the following functions will you use to accomplish the task? |
|
|
0 |
0 |
1 |
0224 |
What will be the output of the following code snippet? |
$string = '133445abcdef';
$mask = '12345';
echo strspn ($string, $mask); |
|
0 |
0 |
1 |
0225 |
Consider the following string: |
ZeNd php |
After running a PHP script, the above string is converted in the following format: |
0 |
0 |
1 |
0226 |
You want to search for such users who have not used any digit in their user names to register to your Website. Which of the following regular expressions will you use to accomplish the task? |
|
|
0 |
0 |
1 |
0227 |
What will be the output of the following code snippet? |
echo 'hello ' . 1 + 2 . '34'; |
|
0 |
0 |
1 |
0228 |
You run the following PHP script: |
$x = 'john';
echo substr_replace($x, 'jenny', 0, 0); |
|
0 |
0 |
1 |
0229 |
Consider a string in the following format: |
a*bcd/a.d |
You want to perform regular expression in this string; however, you are unable to do this since the string contains special characters. You can make this string PCRE compatible if you convert this string in the following format: |
0 |
0 |
1 |
0230 |
Consider the following array: |
$arr = ['apple', 'banana', 'cherry']; |
Which function would you use to get the following string? |
0 |
0 |
1 |
0231 |
What will be the output of the following PHP code snippet? |
echo <<<"FOOBAR"
Hello World!
FOOBAR; |
|
0 |
0 |
1 |
0232 |
Consider the following code snippet: |
$hello = 'world';
$world = 'hello';
echo $$$hello; |
What will be the output? |
0 |
0 |
1 |
0233 |
Which of the following metacharacters can be used to find a non-word character? |
|
|
0 |
0 |
1 |
0234 |
Which of the following functions will you use to break a string into an array based on a specific pattern? Each correct answer represents a complete solution. Choose all that apply. |
|
|
0 |
0 |
1 |
0235 |
Which of the following PCRE expressions is used to match any white space character? |
|
|
0 |
0 |
1 |
0236 |
You want to parse the following string in PHP: |
$some_string="Student\tJohn\nMichel\tMaria"; |
Which of the following PHP functions will you use to parse the string according to the \t and \n characters? |
0 |
0 |
1 |
0237 |
Consider the following PHP code: |
<?= strlen(md5(rand(),TRUE)); |
|
0 |
0 |
1 |
0238 |
Which of the following functions can be used to compare two strings using a case-insensitive binary algorithm? |
|
|
0 |
0 |
1 |
0239 |
Consider the following PHP script: |
$charlist = [
'a' => 'one',
'b' => 'two',
];
// ***** |
What statement will you write at line number 5 instead of ***** to get the output onectwo? |
0 |
0 |
1 |
0240 |
Consider the following PHP code snippet: |
$who = "World";
echo <<<TEXT
"Hello $who"
TEXT; |
What will be the output? |
0 |
0 |
1 |
0241 |
Fill in the blank with the appropriate term. The ____ function is used to reverse a given string. *Matching is case-insensitive. |
|
|
0 |
0 |
1 |
0242 |
You are using a database named HumanResource. You have to delete some tables from the database using SQL statements. Which of the following statements will you use to accomplish the task? |
|
|
0 |
0 |
1 |
0243 |
You have been given the following code snippet: |
$stmt = $dbh->prepare("SELECT * FROM USER where name = ?");
if ($stmt->execute(array($_GET['name']))) {
while (??????) {
print_r($row);
}
} |
What will you write at line number 4 to fetch data from database? |
0 |
0 |
1 |
0244 |
A table named employees is given below: |
|
Which of the following statements would return the employees' names, in ascending order, based on their last name and first name? |
0 |
0 |
1 |
0245 |
Symonds works as a Database Administrator for Blue Well Inc. The company uses an Oracle database. The database contains a table named Employees. Following is the structure of the table: |
EmployeeID NUMBER (5) PRIMARY KEY
EmployeeName VARCHAR2 (35) NOT NULL
Salary NUMBER (9, 2) NOT NULL
Commission NUMBER (4, 2)
DepartmentID NUMBER (5) |
Which of the following types of joins is used in the statement? |
0 |
0 |
1 |
0246 |
Which of the following statements describes the use of a GROUP BY clause? |
|
|
0 |
0 |
1 |
0247 |
Angela works as a Database Administrator for AznoTech Inc. She writes the following query: |
SELECT Dept_Name, Emp_Name
FROM Departments d1, Employees e1
WHERE d1.Dept_No = e1.Dept_No
ORDER BY Dept_Name, Emp_Name; |
Which of the following joins is used in this query? |
0 |
0 |
1 |
0248 |
Which of the following prepared query strings is used to execute a prepared statement? |
|
|
0 |
0 |
1 |
0249 |
You work as a Database Administrator for Dolliver Inc. The company uses an Oracle database. The database contains two tables, named Employees and Departments. You want to retrieve all matched and unmatched rows from both the tables. Which of the following types of joins will you use to accomplish this? |
|
|
0 |
0 |
1 |
0250 |
Which of the following methods of PDOStatement class returns the next rowset in a multi-query statement? |
|
|
0 |
0 |
1 |
0251 |
Martin works as a Database Administrator for MTech Inc. He designs a database that has a table named Products. He wants to create a report listing different product categories. He does not want to display any duplicate row in the report. Which of the following SELECT statements will Martin use to create the report? |
|
|
0 |
0 |
1 |
0252 |
You have a table created as follows: |
create table foo (c1 int, c2 char(30), c3 int, c4 char(10)) |
If column c1 is unique, which of the following indexes would optimize the statement given below? |
0 |
0 |
1 |
0253 |
You have created a table based on the following data: |
EmpID NUMBER (5) PRIMARY KEY
EmpName VARCHAR2 (35) NOT NULL
Salary NUMBER (9, 2) NOT NULL
Commission NUMBER (4, 2)
ManagerName VARCHAR2 (25)
ManagerID NUMBER (5) |
Now, you want to display the names of employees who are managers, using a self join. Which of the following SQL statements can you use to accomplish this? |
0 |
0 |
1 |
0254 |
Maria writes a query that uses outer join between two tables. Which of the following operators are not allowed in the query? Each correct answer represents a complete solution. Choose two. |
|
|
0 |
0 |
1 |
0255 |
You have to select persons whose age is between twenty-five and forty from a database named HumanResource. Which of the following criteria will you use in the query to accomplish the task? |
|
|
0 |
0 |
1 |
0256 |
You want to retrieve all the data from any given table. You also want to ensure that no duplicate values are displayed. Which of the following SQL statements will you use to accomplish the task? |
|
|
0 |
0 |
1 |
0257 |
Which of the following joins retrieves all rows from one table and only the matching rows from the joined table? |
|
|
0 |
0 |
1 |
0258 |
Which of the following joins will you use to display data that do not have an exact match in the column? |
|
|
0 |
0 |
1 |
0259 |
You want to check whether the header has already been sent or not. Which of the following code segments will you use to accomplish the task? |
|
|
0 |
0 |
1 |
0260 |
You are using a database named SalesDB to keep all sales records. The SalesDB database contains a table named Orders. You are required to create a new table named OldOrders and transfer all the data from the Orders table to the new table. Which of the following statements will you use to accomplish the task? |
|
|
0 |
0 |
1 |
0261 |
Which of the following are the limitations of the prepared statements? Each correct answer represents a complete solution. Choose all that apply. |
|
|
0 |
0 |
1 |
0262 |
Which of the following recovers the committed transaction updates against any kind of system failure? |
|
|
0 |
0 |
1 |
0263 |
In which of the following ways will you receive data from a Web page if you do not know how data is sent? |
|
|
0 |
0 |
1 |
0264 |
You want to make a cookie available only for the HTTP protocol. Which of the following setcookie() parameters would you use to accomplish this? |
|
|
0 |
0 |
1 |
0265 |
Which of the following HTML code snippets can be used for the file uploading? |
|
|
0 |
0 |
1 |
0266 |
Fill in the blank with the appropriate function name. The __ function is used to encode a URL. *Matching is case-insensitive. |
|
|
0 |
0 |
1 |
0267 |
You allow PHP to dynamically choose whether to propagate the session identifier via cookies or the URL, depending on the user's preferences. Which of the following PHP.ini directives will you use? |
|
|
0 |
0 |
1 |
0268 |
You want to send an HTTP cookie without URL encoding the cookie value. Which of the following functions will you use? |
|
|
0 |
0 |
1 |
0269 |
Which of the following code snippets will you use to redirect your users from one page to another? |
|
|
0 |
0 |
1 |
0270 |
What is the result of the following code? |
$x = new class extends \stdClass {
function getName() {
return 'PHP';
}
};
echo $x->getName(); |
|
0 |
0 |
1 |
0271 |
You want to enable compression for every Web page of your Website. Which of the following PHP.ini directives can you set to accomplish the task? Each correct answer represents a complete solution. Choose all that apply. |
|
|
0 |
0 |
1 |
0272 |
Which of the following header codes is used for redirection? |
|
|
0 |
0 |
1 |
0273 |
The dl() function is used to load PHP extensions on the server at runtime. However, you want to disable it due to some security issue. Which of the following actions will you perform to accomplish the task? |
|
|
0 |
0 |
1 |
0274 |
Consider the following PHP script: |
header("Content-type:application/pdf");
header("Content-Disposition:attachment;filename='2.pdf'");
readfile("1.pdf"); |
What will be the default name of the downloaded pdf? |
0 |
0 |
1 |
0275 |
Which of the following statements correctly explains the working of the following code snippet? |
header( "Location: http://www.zendexam.com" ); |
|
0 |
0 |
1 |
0276 |
You have been given the following PHP script: |
<?php
if ($_POST) {
echo '<pre>';
echo htmlspecialchars(print_r($_POST, true));
echo '</pre>';
}
?>
<form action="action.php" method="post">
Name: <input type="text" name="personal[name]" />
Email: <input type="text" name="personal[email]" />
Code:
// ???
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<input type="submit" value="submit me!" />
</form> |
Which of the following is the correct syntax that should be used in line number 10 to capture all of the data from the user in PHP? |
0 |
0 |
1 |
0277 |
Fill in the blank with the appropriate function name. The __ function is used to set a cookie to be sent along with the rest of the HTTP headers. |
|
|
0 |
0 |
1 |
0278 |
Consider the following PHP code snippet: |
<form method=get>
<select name ="fruits" id="fruits">
<option value="1">Apple</option>
<option>Orange</option>
<option value="3">Strawberry</option>
</select>
<input type="submit" value="Submit">
<?= $_GET['fruits'] ?? ''; ?> |
What will be the output if you select 'Orange' from the dropdown menu? |
0 |
0 |
1 |
0279 |
You have been given the following code snippet: |
<?php
$string = <<<XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<email>
<to>[email protected]/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</to>
<from>[email protected]/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){fo |
Which of the following code snippets will you write to print the XML content? |
0 |
0 |
1 |
0280 |
What is the maximum limit of the file size that a user can upload according to the code snippet given below? |
<form enctype="multipart/form-data" action="index.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="5000" />
<input name="filedata" type="file" />
<input type="submit" value="Send file" />
</form> |
|
0 |
0 |
1 |
0281 |
Which of the following superglobals can you use to fetch a cookie from the client's side? Each correct answer represents a complete solution. Choose all that apply. |
|
|
0 |
0 |
1 |
0282 |
What will be the output of the following PHP code? |
array_combine([1,2,3], [4,5,6]); |
|
0 |
0 |
1 |
0283 |
You have the following code in the welcome.html file: |
<form action="welcome.php" method="post">
Your Name: <input type="text" name="fname" />
Your Girl Friend Name: <input type="text" name="fname" />
<input type="submit" />
</form> |
The PHP code of the welcome.php file is as follows: |
0 |
0 |
1 |
0284 |
Which of the following statements is true about deleting a client's cookie? |
|
|
0 |
0 |
1 |
0285 |
You want to destroy session variables within a PHP session. Which of the following methods can you use to accomplish the task? |
|
|
0 |
0 |
1 |
0286 |
What is the work of simplexml_import_dom() in the following PHP code? |
$dom = new domDocument;
$dom->loadXML('<email><from>John</from></email>');
$xml = simplexml_import_dom($dom);
echo $xml->from; |
|
0 |
0 |
1 |
0287 |
You want to enable compression in the PHP code output. Which of the following ways should you prefer most? |
|
|
0 |
0 |
1 |
0288 |
Which of the following is an associative array of items uploaded by the current PHP script via the HTTP POST method? |
|
|
0 |
0 |
1 |
0289 |
Which of the following file permissions is set by the tempnam() function for the newly created temp file? |
|
|
0 |
0 |
1 |
0290 |
Which of the following functions can be used to get whether or not a file is readable? |
|
|
0 |
0 |
1 |
0291 |
Fill in the blank with the appropriate function().
The ___ function is used to copy data from one stream to another. It is mainly useful in copying data between two open files. *Matching is case-insensitive. |
|
|
0 |
0 |
1 |
0292 |
You run the following PHP script: |
<?= gethostbyaddr($_SERVER['REMOTE_ADDR']); |
What will be the output of the script? |
0 |
0 |
1 |
0293 |
Which of the following statements is true about __FILE__ constant? |
|
|
0 |
0 |
1 |
0294 |
Consider the following PHP script: |
$fp = fopen('file.txt', 'r');
$string1 = fgets($fp, 512);
fseek($fp, 0); |
Which of the following functions will give the same output as that given by the fseek() function in the above script? |
0 |
0 |
1 |
0295 |
What does the second parameter of the file_get_contents() function do? |
|
|
0 |
0 |
1 |
0296 |
Which of the following functions is used to delete a file? |
|
|
0 |
0 |
1 |
0297 |
Which of the following PHP functions can be used to alter the amount of time PHP waits for a stream before timing out during reading or writing? |
|
|
0 |
0 |
1 |
0298 |
Which of the following file functions can be used to indicate the current position of the file read/write pointer? |
|
|
0 |
0 |
1 |
0299 |
You want to check whether the uploaded file is blank or not. How will you do this? Each correct answer represents a complete solution. Choose all that apply. |
|
|
0 |
0 |
1 |
0300 |
Fill in the blank with the appropriate PHP function. The ___ function generates a file resource having 0600 file permission in the file system with a randomly-generated filename to be used as temporary storage. *Exact matching is required. |
|
|
0 |
0 |
1 |
0301 |
Which of the following functions will you use to read a file having single line irrespective of length? Each correct answer represents a complete solution. Choose two. |
|
|
0 |
0 |
1 |
0302 |
Which of the following PHP file handling functions will you use if you want to retrieve only the texts from an HTML file and leave all HTML and PHP tags? |
|
|
0 |
0 |
1 |
0303 |
Which of the following functions will you use to change the number of bytes to buffer? |
|
|
0 |
0 |
1 |
0304 |
Which of the following functions will you use to copy data between two opened files? |
|
|
0 |
0 |
1 |
0305 |
Which of the following can be used to release the lock applied by the flock() function where fp is a file pointer? Each correct answer represents a complete solution. (Choose two) |
|
|
0 |
0 |
1 |
0306 |
If you want to read exactly one byte of a file. Which of the following functions will you use to accomplish the task? Each correct answer represents a complete solution. (Choose two) |
|
|
0 |
0 |
1 |
0307 |
Which of the following code snippets write content from one file to another file? Each correct answer represents a complete solution. Choose all that apply. |
|
|
0 |
0 |
1 |
0308 |
What is the output of the following PHP script: |
$a = 10;
$b = 20;
$c = 30;
echo ($a < 50 && $b > 100 || $c == 30) ? "a" : "b";
echo ($b < 50 XOR $c == 30) ? "c" : "d"; |
Enter the exact script output |
0 |
0 |
1 |
0309 |
What is the output of the following PHP script: |
$a = 0;
if ($a = 10) {
echo "a";
}
if ($a == 0) {
echo "b";
}
if ($a == "0") {
echo "c";
} |
Enter the exact script output |
0 |
0 |
1 |
0310 |
Which of the following statements best describes the @ operator when used in PHP code? |
|
|
0 |
0 |
1 |
0311 |
Which of the statements below best describe the following PHP code. Note that backticks are being used (not single quotes). |
$output = `ls`; |
|
0 |
0 |
1 |
0312 |
PHP assigns non-object variables by value, but you can "connect" one variable to another so assignment occurs by reference instead. What is output of the following PHP script? |
$a = 15;
$b = $a;
$b = 25;
$c = 50;
$d = &$c;
$d = 25;
echo $a . ' - ' . $c; |
Enter the exact script output |
0 |
0 |
1 |
0313 |
What is output of the following PHP script? |
$str = 'foo';
$str .= 'bar';
$num = 0;
$num += 25;
$num -= 15;
echo $str . ' - ' . $num; |
|
0 |
0 |
1 |
0314 |
What is the output of the following PHP script? |
$a = ($b = 13) - 5;
echo $a . ' - ' . $b; |
|
0 |
0 |
1 |
0315 |
What is the output of the following PHP script? |
$i = 100;
$j = $i++ - 10;
echo $i . ' - ' . $j; |
|
0 |
0 |
1 |
0316 |
Consider the use of bitwise operators on hexadecimal values. What is the output of the following PHP script? |
$a = 0xF0;
$b = 0x0F;
$val1 = $a & $b; // bitwise AND
$val2 = $a | $b; // bitwise OR
$val3 = $a ^ ($b | $a); // bitwise XOR
echo sprintf('0x%02X - 0x%02X - 0x%02X', $val1, $val2, $val3); |
|
0 |
0 |
1 |
0317 |
What is the output of the following PHP script? |
$a = 10 * 5 + 8;
$b = 4 * 6 - 10 / 2;
$c = 8 / (12 - 8) * 4;
echo $a . ' - ' . $b . ' - ' . $c; |
Enter the exact script output |
0 |
0 |
1 |
0318 |
What is the output of the following PHP script? |
$a = 25;
echo $a % 10; |
|
0 |
0 |
1 |
0319 |
The bitwise left shift (>) operands move the bits in the left operand left or right by the number of positions in the right operand. This is in effect a fast way to multiple or divide by powers of 2. What is the output of the following script? |
$a = 15 << 2;
$b = 10 >> 1;
$c = 0xF0 >> 4;
echo sprintf('%d - %d - 0x%X', $a, $b, $c); |
|
0 |
0 |
1 |
0320 |
What is the output of the following PHP script: |
$a = "1";
$b = "01";
echo ($a == $b) ? "a" : "b";
echo ($a === $b) ? "c" : "d";
echo ($a < $b) ? "e" : "f"; |
|
0 |
0 |
1 |
0321 |
What is the output of the following PHP script? |
$a = array('z', 'x');
$b = array('y', 'w');
$c = array('a' => 1, 'b' => 2);
$d = array('c' => 3, 'd' => 4);
$e = $a + $b;
$f = $c + $d;
foreach ($e as $value) {
echo $value;
}
foreach ($f as $value) {
echo $value;
} |
Enter the exact script output |
0 |
0 |
1 |
0322 |
What is the output of the following PHP script: |
$a = 10;
$b = "10";
if ($a == $b) {
echo "a";
} else {
echo "b";
}
if ($a === $b) {
echo "c";
} else {
echo "d";
} |
Enter the exact script output |
0 |
0 |
1 |
0323 |
What is the output of the following PHP (PHP7) script? |
$string1 = 'foo' . 'bar';
$string2 = 'hello' + 'goodbye';
$string3 = "abc" + "123";
echo sprintf('%s - %s - %s', $string1, $string2, $string3); |
Enter the exact script output |
0 |
0 |
1 |
0324 |
What is the output of the following PHP script? |
$myVar = 'foo';
$$myVar = 'bar';
echo $'myVar'; |
|
0 |
0 |
1 |
0325 |
What is the output of the following script? |
$varName = 'abc';
$$varName = '123';
echo $abc; |
Enter the exact script output |
0 |
0 |
1 |
0326 |
What is the output of the following PHP script? |
function getName($lastName) {
if ($lastName) {
return 'Bloggs';
} else {
return 'Jeremiah';
}
}
$func = 'getName';
echo $func(true); |
Enter the exact script output |
0 |
0 |
1 |
0327 |
What is the output of the following PHP script? |
$myVar = 'foo';
$$myVar = 'bar';
echo ${'myVar'} . $foo; |
|
0 |
0 |
1 |
0328 |
Of the following options, which are valid variable names? |
|
|
0 |
0 |
1 |
0329 |
What is the output of the following PHP script? |
$name = 'Joe';
$$name = 'Bloggs';
echo ${$name}; |
Enter the exact script output |
0 |
0 |
1 |
0330 |
How do you check if a variable $name exists in the current scope in a PHP script? |
|
|
0 |
0 |
1 |
0331 |
How do you check if a constant called DEBUG_LEVEL exists in your PHP code? |
|
|
0 |
0 |
1 |
0332 |
What is the output of the following PHP script? |
define('123MESSAGE', '123');
if (strlen(123MESSAGE) == 12) {
echo 123MESSAGE;
} else {
echo 'ABC';
} |
|
0 |
0 |
1 |
0333 |
What is the output of the following PHP script? |
define('SOMEVAL', 0);
if (strlen(SOMEVAL) > 0) {
echo "Hello";
} else {
echo "Goodbye";
} |
|
0 |
0 |
1 |
0334 |
What is the output of the following PHP script? |
define('MYCONSTANT', 0);
if (empty(MYCONSTANT)) {
echo "Hello";
} else {
echo "Goodbye";
} |
|
0 |
0 |
1 |
0335 |
What is the output of the following script? |
$number = 100;
echo $number < 10 ? "a" : ($number > 100 ? "b" : "c"); |
|
0 |
0 |
1 |
0336 |
What is the output of the following PHP script? |
$arr = array(1, 2, 3, 4);
foreach ($arr as $value) {
$value -= 1;
}
foreach ($arr as &$value) {
$value *= 2;
}
foreach ($arr as $v) {
if ($v <= 8) {
echo $v;
}
} |
|
0 |
0 |
1 |
0337 |
What is the output of the following script? |
$x = 5;
$y = $x << 1;
switch ($x + $y) {
case 5:
echo "a";
break;
case 10:
echo "b";
break;
case 15:
echo "c";
case 20:
echo "d";
break;
default:
echo "e";
} |
|
0 |
0 |
1 |
0338 |
What is the output of the following PHP script? |
$colors = ['r' => 'f00', 'g' => '0f0', 'b' => '00f'];
next($colors);
foreach ($colors as $k => $v) {
echo $k;
}
reset($colors);
while (list($v, $k) = each($colors)) {
echo $v;
} |
|
0 |
0 |
1 |
0339 |
What is the output of the following PHP script? |
for ($i = ord('a'); $i < ord('e'); $i++);
echo chr($i); |
|
0 |
0 |
1 |
0340 |
What is the output of the following script? |
$str = "Hello";
if ($str == "Hello") {
echo "a";
} else if ($str == "Goodbye") {
echo "b";
} elseif ($str == "Hello") {
echo "c";
} else
echo "d"; |
|
0 |
0 |
1 |
0341 |
What is the output of the following PHP script? |
for ($i = 5; ; $i++) {
if ($i < 10) {
break;
}
}
echo $i; |
Enter the exact script output |
0 |
0 |
1 |
0342 |
What is the output of the following script? |
$x = 5;
switch ($x) {
case 5:
echo "a";
break;
case 10:
echo "b";
break;
case 15:
echo "c";
break;
case 20:
echo "d";
break;
case default:
echo "e";
} |
|
0 |
0 |
1 |
0343 |
What is the output of the following PHP script? |
$myArray = array('a', 'b', 'c');
foreach ($myArray as $k => $v) {
echo $v;
for ($i = 1; $i < 5; $i++) {
if ($i == $k) {
break(2);
}
echo $i;
}
} |
Enter the exact script output |
0 |
0 |
1 |
0344 |
What is the output of the following script? |
$number = 15;
if ($number > 15);
for ($i = 1; $i < 5; $i++)
echo $i;
echo $number; |
|
0 |
0 |
1 |
0345 |
Consider the following code, stored inside the myInclude.php file. |
$foo = "Bar";
return $foo; |
What happens when you include this script from another script (main.php), given that myInclude.php is calling return when not inside a function. |
0 |
0 |
1 |
0346 |
What is the output of the following PHP script? |
$myArray = array(1, 2, 3);
for ($i = 0, $length = count($myArray); $i < $length; $i++) {
echo $myArray[$i];
} |
Enter the exact script output |
0 |
0 |
1 |
0347 |
What is the output of the following PHP script? |
$i = 5;
while (--$i > 0) {
echo $i + 1;
} |
Enter the exact script output |
0 |
0 |
1 |
0348 |
What is the difference between including a script with include() and require()? |
|
|
0 |
0 |
1 |
0349 |
What is the output of the following PHP script? |
for ($i = 0; $i < 3; $i++) {
for ($j = 3; $j > 0; $j--) {
if ($i == $j) {
break;
}
echo $j;
}
} |
|
0 |
0 |
1 |
0350 |
The following script is supposed to determine the largest value in an array, however, it may not work correctly. Examine the script and recommend changes if required. |
$ages = array(16, 10, 46, 25, 41);
$largest = -1;
foreach ($ages as $age) {
if ($largest < 0) {
$largest = $age;
break;
}
if ($age > $largest) {
$largest = $age;
}
}
echo sprintf('The largest age is %d', $largest); |
|
0 |
0 |
1 |
0351 |
What is the output of the following PHP script? |
$i = ord('a');
do {
echo chr($i);
} while ($i++ < ord('f') + 1); |
Enter the exact script output |
0 |
0 |
1 |
0352 |
What is the output of the following script? |
$number = 25;
if ($number <= 25) {
echo "lte";
} else if ($number == 25) {
echo "e";
} else if ($number >= 25) {
echo "gte";
} else {
echo "o";
} |
Enter the exact script output |
0 |
0 |
1 |
0353 |
How do you comment out code in a PHP script? |
|
|
0 |
0 |
1 |
0354 |
What is the output of the following code, if any? Note the extra comma in the array declaration. |
$anArray = array('x', 'y', 'z');
foreach ($anArray as $k => $val) {
if ($k == 0) {
echo $val;
}
} |
|
0 |
0 |
1 |
0355 |
What is the primary reason for omitting the code ?> in a PHP script? |
|
|
0 |
0 |
1 |
0356 |
Is the following code valid, or will it cause a syntax error? Note the missing semi-colon at the end of the statement. |
<?= "Hello" ?> |
|
0 |
0 |
1 |
0357 |
What is the function used to define a custom error handling function? |
|
|
0 |
0 |
1 |
0358 |
What expression would you pass to error_reporting() if you want all errors and warnings (including "strict" warnings), but not notices (E_NOTICE)? |
|
|
0 |
0 |
1 |
0359 |
This question tests your knowledge of boolean values and casting. What is the output of the following PHP script. |
$myInt = -1;
$myBool = (bool) $myInt;
if ($myBool > 0) {
echo "5";
} else if ($myBool == true) {
echo "6";
} else if (!$myBool) {
echo "7";
} else {
echo sprintf("%d", $myBool);
} |
Enter the exact script output |
0 |
0 |
1 |
0360 |
What is the output of the following PHP script. |
$int1 = 25;
$int2 = 10;
$int3 = ceil($int1 / $int2);
$int4 = ceil((int) ($int1 / $int2));
echo $int3 . ' - ' . $int4; |
|
0 |
0 |
1 |
0361 |
What is the output of the following script. All output values are integers. |
echo 100;
echo 0xf;
echo 010; |
|
0 |
0 |
1 |
0362 |
What is the output of the following PHP script. |
if ("") {
echo "a";
}
if (1) {
echo "b";
} else if (-2) {
echo "c";
}
if ("foo") {
echo "d";
}
if (array(12)) {
echo "e";
}
if (array()) {
echo "f";
}
if ("false") {
echo "g";
} |
|
0 |
0 |
1 |
0363 |
What PHP function is used to create a new array pre-filled with a sequential series of values? |
|
|
0 |
0 |
1 |
0364 |
What is the output of the following PHP script? |
$values = [
10, 20, '0',
'123hello',
'hello123'
];
echo array_sum($values); |
Enter the exact script output |
0 |
0 |
1 |
0365 |
How do you add the value 10 to an array called $myArray? |
|
|
0 |
0 |
1 |
0366 |
The array_search() function is used to determine the array key for a given value. If the value is not found then false is returned. What is the output of the following PHP script? |
$values = [15, 12, "15", 34, 15 => 25];
$key = array_search("15", $values);
if (!$key) {
echo "Not found";
} else {
// gettype() will return either 'string' or 'integer'
echo $key . ' - ' . strtolower(gettype($values[$key]));
} |
|
0 |
0 |
1 |
0367 |
What is the output of the following PHP script? |
$arr1 = ['a' => 'Apple', 'b' => 'Banana'];
$arr2 = ['b' => 'Banana', 'a' => 'Australia', 'Apple'];
$arr3 = array_diff($arr1, $arr2);
$arr4 = array_diff($arr2, $arr1);
$keys = array_keys($arr4);
echo count($arr3) . ' - ' . $keys[0]; |
|
0 |
0 |
1 |
0368 |
Which of the following statements best describes the purpose of PHP's extract() function? This function accepts an array as its first argument. |
|
|
0 |
0 |
1 |
0369 |
What is the output of the following code? |
$myArray = array();
array_unshift($myArray, 10, 20);
echo $myArray[0]; |
|
0 |
0 |
1 |
0370 |
What line should be added to the cleanArray() function below to ensure this script outputs 1525hello? |
function cleanArray($arr) {
$functions = array();
/** line **/
$ret = $arr;
foreach ($functions as $func) {
$ret = $func($ret);
}
return $ret;
}
$values = [15, '', 0, 25, 'hello', 15];
foreach (cleanArray($values) as $v) {
echo $v;
} |
|
0 |
0 |
1 |
0371 |
Consider the following PHP code: |
$myArray = [10, 20, 30, 40]; |
What is the simplest way to return the values 20 and 30 in a new array without modifying $myArray? |
0 |
0 |
1 |
0372 |
What is the primary difference between array_key_exists() and isset() when checking to see if a given array element exists? |
|
|
0 |
0 |
1 |
0373 |
What function is used to remove and return the first element of an array? |
|
|
0 |
0 |
1 |
0374 |
What is the output of the following PHP code? |
$myArray = [0, NULL, '', '0', -1];
echo count(array_filter($myArray)); |
|
0 |
0 |
1 |
0375 |
What PHP function is used to return an array containing values present in two or more passed arrays? |
|
|
0 |
0 |
1 |
0376 |
Which function is used to return true if a given value exists in an array (and false if it doesn't)? |
|
|
0 |
0 |
1 |
0377 |
Which of the following statements best describes what happens to an array when array_shift() is called on it? |
|
|
0 |
0 |
1 |
0378 |
How do you determine the number of elements in array? |
|
|
0 |
0 |
1 |
0379 |
In the following code, what are the values required in $a, $b, $c and $d to output 40? |
$values = array(
array(
1 => 10,
20,
array(30, array(40))
),
array(
2 => 50,
array(
array(1 => 60, 0 => 70)
)
)
);
echo $values[$a][$b][$c][$d]; |
|
0 |
0 |
1 |
0380 |
How do you remove an element with the key 0 from the array $numbers? |
|
|
0 |
0 |
1 |
0381 |
How do you create an array called $arr consisting of a single element with the value 15? |
|
|
0 |
0 |
1 |
0382 |
Given the $info array defined below, what is an easy way to assign the first value to a variable called $name and the third value to a variable called $country? |
$info = ['Paul', 31, 'Australia']; |
|
0 |
0 |
1 |
0383 |
In the following code, what is the key of the element with value 25? |
$myArray = ['foo' => 'bar', 7 => 15, 28];
$myArray[] = 25; |
|
0 |
0 |
1 |
0384 |
Is the following PHP code valid or will it generate an error, warning or notice? |
error_reporting(E_ALL | E_STRICT);
$newArray[E_STRICT] = 'foo'; |
|
0 |
0 |
1 |
0385 |
Consider the following PHP script, used to apply a callback function to every element of an array. |
function square($val) {
return pow($val, 2);
}
$arr = [1, 2, 3, 4];
/** line **/
$i = 0;
foreach ($squares as $value) {
if ($i++ > 0) {
echo ".";
}
echo $value;
} |
What line of code should be substituted with / line / to achieve an output of 1.4.9.16? |
0 |
0 |
1 |
0386 |
What is the output of the following PHP script? |
$arr = array_flip(['a' => 1, 'b' => 2, 'c' => 3]);
foreach (array_values($arr) as $k => $v) {
echo $k;
} |
|
0 |
0 |
1 |
0387 |
What is the output of the following PHP script? |
$cars = ['year' => 2010, 'make' => 'Porsche', 'model' => 911];
while ($value = next($cars)) {
echo $value;
} |
|
0 |
0 |
1 |
0388 |
What is the output of the following PHP script? |
$car = ['year' => 2010, 'make' => 'Porsche', 'model' => 911];
next($car);
foreach ($car as $k => $v) {
echo $v;
} |
Enter the exact script output |
0 |
0 |
1 |
0389 |
What is the output of the following PHP script? |
$numbers = array(5, 6, 7, 8);
end($numbers);
while (key($numbers)) {
echo current($numbers);
prev($numbers);
} |
|
0 |
0 |
1 |
0390 |
Which of the following phrases best describes what is required to make this script output 41234? |
class SomeClass {
private $_values = [1, 2, 3, 4];
}
$obj = new SomeClass;
echo count($obj);
foreach($obj as $v) {
echo $v;
} |
|
0 |
0 |
1 |
0391 |
The PHP function array_reduce() is used to turn an array into a single value using a custom callback. What is the output of the following script? |
function reducer($total, $elt) {
return $elt + $total;
}
$arr = [1, 2, 3, 4, 5];
echo array_reduce($arr, 'reducer', 1); |
|
0 |
0 |
1 |
0392 |
Which of the following statements best describes the shuffle() function. This function accepts an array as its first argument. |
|
|
0 |
0 |
1 |
0393 |
In the PHP script below, what line of code should be substituted with / line / to achieve an output of eeeeee? |
function sortByLength($a, $b) {
$lenA = strlen($a);
$lenB = strlen($b);
if ($lenA == $lenB) { return 0; }
/** line **/
}
$values = ['ccc', 'a', 'eeeeee', 'dddd', 'bb', 'fffff'];
usort($values, 'sortByLength');
echo $values[5]; |
|
0 |
0 |
1 |
0394 |
Remembering that keys are not reset when using natsort(), what is the output of the following PHP script? |
$filenames = array(
'img12.png',
'img7.png',
'img21.png',
'img1.png'
);
natsort($filenames);
$values = array_values($filenames);
echo $values[1]; |
Enter the exact script output |
0 |
0 |
1 |
0395 |
What is the output of the following PHP script? |
$values = array(37, 5, "09");
$sorted = sort($values, SORT_STRING);
foreach ($sorted as $v) {
echo $v;
} |
|
0 |
0 |
1 |
0396 |
When defining a custom sorting callback for functions such as usort(), uksort() or uasort(), you must return 0 if two elements are considered equal. Which of the following statements best describes how PHP treats equal elements during sorting? |
|
|
0 |
0 |
1 |
0397 |
Consider the following PHP code, which defines an associative array of fruits and vegetables. |
$fruitAndVeg = array(
'c' => 'Carrot',
'p' => 'Tomato',
'b' => 'Banana',
't' => 'Potato',
'a' => 'Apple'
);
/** line **/
$keys = array_keys($fruitAndVeg);
echo $keys[0]; |
What line of code should be substituted with / line / to achieve an output of a? |
0 |
0 |
1 |
0398 |
What is the output of the following PHP script? |
$values = array(37, 5, "09");
sort($values, SORT_STRING);
foreach ($values as $v) {
echo $v;
} |
|
0 |
0 |
1 |
0399 |
What is the output of the following PHP script? |
$subs = ['@' => '<at>', 'com' => 'net'];
$email = "your_name@mail.com";
echo strtr($email, $subs); |
Enter the exact script output |
0 |
0 |
1 |
0400 |
The following script defines a function called buildUrl(), which is intended to be a crude way of normalizing URLs. What line of code must be inserted into buildUrl() to ensure $url1 and code $url2 are both equal to http://phpriot.com/quiz/? |
function buildUrl($domain, $path) {
// insert line of code here
return $ret;
}
$domain1 = 'http://phpriot.com/';
$domain2 = 'http://phpriot.com';
$path = '/quiz/';
$url1 = buildUrl($domain1, $path);
$url2 = buildUrl($domain2, $path); |
|
0 |
0 |
1 |
0401 |
What is the output of the following PHP script? |
$str = "It's \"good\"";
echo strlen(addslashes($str)); |
|
0 |
0 |
1 |
0402 |
The str_pad() function is used pad a string to a given length using another string. What is the output of the following PHP script? |
$number = 5;
$len = 3;
$pad = '0';
echo str_pad($number, $len, $pad, STR_PAD_LEFT); |
|
0 |
0 |
1 |
0403 |
What is the key difference between Heredoc and Nowdoc syntax? |
|
|
0 |
0 |
1 |
0404 |
What is the PHP function used to determine the length of a string? |
|
|
0 |
0 |
1 |
0405 |
What is the output of the following script? |
$name = 'Judy';
$str1 = <<<EOF
Hello $name
EOF;
$str2 = <<<'EOF'
Goodbye $name;
EOF;
if (strpos($str1, $name) === false) {
echo 'a';
} else {
echo 'b';
}
if (strpos($str2, $name) === false) {
echo 'c';
} else {
echo 'd';
} |
|
0 |
0 |
1 |
0406 |
What is the output of the following PHP script? |
$str = 'stingers';
echo strtr($str, 'st', 'bl'); |
Enter the exact script output |
0 |
0 |
1 |
0407 |
What is the output of the following PHP script? |
$foo = 'bar';
echo '$foo\'' . "$foo\'"; |
|
0 |
0 |
1 |
0408 |
What is the output of the following script? |
$str = 'val1,val2,,val4,';
echo count(explode(',', $str)); |
Enter the exact script output |
0 |
0 |
1 |
0409 |
What is the PHP function used to make a string all upper-case? |
|
|
0 |
0 |
1 |
0410 |
The parse_str() function is used to parse a query string just as if it were passed in the URL of a HTTP request. If the second argument is included then the parsed values are written to this variable. What is the output of the following script? |
$str = "days=Mon&days=Wed" . "&fruit[1]=Apple&fruit[]=Banana&age=13";
parse_str($str, $output);
// gettype will return 'array' or 'string'
echo gettype($output['days']);
echo ' - ';
// array_search will return the key
// where the first argument is located
echo array_search('Banana', $output['fruit']);
echo ' - ';
echo array_key_exists('age', $output) ? $output['age'] : 0; |
Enter the exact script output |
0 |
0 |
1 |
0411 |
What is the output of the following script? |
$html = '<p>line1line2</p>';
echo strip_tags($html, 'br'); |
Enter the exact script output |
0 |
0 |
1 |
0412 |
What is the PHP function used to make a string all lower-case? |
|
|
0 |
0 |
1 |
0413 |
What is the output of the following script? |
$name = 'John';
$str = <<<EOF
Hello $name
EOF;
echo trim($str); |
|
0 |
0 |
1 |
0414 |
Which of the following statements best describes the difference between delimiting PHP strings with single or double quotes? |
|
|
0 |
0 |
1 |
0415 |
Using htmlspecialchars() is useful for preventing malicious JavaScript from executing, as well as for generating valid HTML. What is the output of the following script? |
$str = <<<EOF
<p>me & you
EOF;
echo htmlspecialchars($str); |
|
0 |
0 |
1 |
0416 |
The following code is intended to format an upper-case string, but it requires two values to be assigned to the $funcs array. Select the line of code that must be inserted for Correct to be output. |
$str = 'MY STRING';
$funcs = array();
// which line goes here?
foreach ($funcs as $func) {
$str = $func($str);
}
echo ($str == 'My string') ? "Correct" : "Incorrect"; |
|
0 |
0 |
1 |
0417 |
What is the output of the following script? |
$str = 'abcd';
echo substr($str, 0, 1);
echo substr($str, 0, -1);
echo substr($str, 3, 1);
echo substr($str, 3);
echo substr($str, -3); |
Enter the exact script output |
0 |
0 |
1 |
0418 |
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); |
Enter the exact script output |
0 |
0 |
1 |
0419 |
What is the output of the following PHP script? |
echo strcmp(5678, '5678'); |
|
0 |
0 |
1 |
0420 |
One way to compare strings in PHP is by using the strcmp() function. This is useful since not only can you determine if two strings are equal, but you can also test if one string is 'greater than' the other (using the corresponding ASCII values in each character comparison). What is the output of the following PHP script? |
$test1 = strcmp('hello', "hello");
$test2 = strcmp("Hello", "hello");
$test3 = strcmp('60', '500');
if ($test1 == 0) { echo "a"; }
else if ($test1 < 0) { echo "b"; }
else { echo "c"; }
if ($test2 == 0) { echo "d"; }
else if ($test2 < 0) { echo "e"; }
else { echo "f"; }
if ($test3 == 0) { echo "g"; }
else if ($test3 < 0) { echo "h"; }
else { echo "i"; } |
Enter the exact script output |
0 |
0 |
1 |
0421 |
The strpos() function is used to determine the position in a string of the given search string. If the search string cannot be found, false is returned. What is the output of the following script? |
$haystack = 'abcda';
$needle = 'a';
$pos = strpos($haystack, $needle);
if (!$pos) {
echo "miss";
} else {
echo "hit " . $pos;
} |
Enter the exact script output |
0 |
0 |
1 |
0422 |
Because PHP dynamically converts variables to different types as needed, you must be careful when performing string comparisons. What is the output of the following PHP script? |
$str1 = '57 channels';
$str2 = '1/2 a pack of cigarettes';
$str3 = '0x10';
if ($str1 == 57) { echo 'a'; }
else { echo 'b'; }
if ($str2 == 0.5) { echo 'c'; }
else if ($str2 == 1) { echo 'd'; }
else { echo 'e'; }
if ($str3 == 0) { echo 'f'; }
else if ($str3 == 16) { echo 'g'; } // 0x10 is 16 in decimal
else if ($str3 == 0x10) { echo 'h'; } |
|
0 |
0 |
1 |
0423 |
What is the output of the following PHP script? |
$a = 0.5;
$b = 0.1;
$c = 16;
echo sprintf('%01.2lf %.1lf 0x%x', $a, $b, $c); |
|
0 |
0 |
1 |
0424 |
What is the output of the following string? |
$str = printf('%.1f', 7.1);
echo trim('PHP ' . $str); |
Enter the exact script output |
0 |
0 |
1 |
0425 |
What value should be assigned to $format to ensure the following script outputs 250007? It must use the d formatter. |
$number1 = 250;
$number2 = 7;
$format = '???';
echo sprintf($format, $number1);
echo sprintf($format, $number2);
// output is 250007 |
Do not include quotes |
0 |
0 |
1 |
0426 |
The sscanf() function is to some extent the opposite of sprintf(), in that it extracts values from a string based on a formatting string. What is the output of the following PHP script? |
$str = 'I am 30';
$vals = sscanf($str, '%s %d');
echo trim($vals[0] . ' ' . $vals[1]); |
|
0 |
0 |
1 |
0427 |
One way to format currencies in PHP is to use the built-in money_format() function. Before using it you must set the locale for the type of currency you're trying to format. What is the output of the following PHP script? The currency name for en_US is USD and uses $ as the currency symbol. Additionally, there are 100 cents to the dollar. |
setlocale(LC_MONETARY, 'en_US');
$amt = 100;
echo money_format('%.2n', $amt); |
|
0 |
0 |
1 |
0428 |
Which of the following statements best describes how number_format() works? |
|
|
0 |
0 |
1 |
0429 |
Given the following PHP code, what value must be assigned to $format so each digit is extracted individually in the call to sscanf()? |
$str = '31337';
$format = '???';
$digits = sscanf($str, $format);
var_dump($digits); |
|
0 |
0 |
1 |
0430 |
What is the output of the following: |
$m = 3;
$n = 0;
function l() {
$m = 0;
$m++;
global $n;
return array($n,$m);
}
echo implode((L(l())),','); |
|
0 |
0 |
1 |
0431 |
What would be output when the following code is run? |
class M {
function m() {
echo "M";
}
function construct() {
echo "mmm";
}
}
$m = new M();
$m->m(); |
|
0 |
0 |
1 |
0432 |
Which of the following could be used to add a book to an existing SimpleXMLElement object stored in $library representing a collection of books? |
|
|
0 |
0 |
1 |
0433 |
What is the output of the following line of code: |
$a = 4 << 2 + 1;
echo $a; |
|
0 |
0 |
1 |
0434 |
Which of the following is a valid way to pass the $callback parameter expected by array_walk()? (choose three) |
|
|
0 |
0 |
1 |
0435 |
How would you parse a web page at http://example.com/page.php as XML? |
|
|
0 |
0 |
1 |
0436 |
How many parameters does array_merge() accept? |
|
|
0 |
0 |
1 |
0437 |
What would you expect to get from PDOStatement::fetch() in its default mode? |
|
|
0 |
0 |
1 |
0438 |
What is the output of the following code? |
$pattern = '/[a-z]{4} /';
$string = 'Mary had a little lamb';
$matches = preg_match($pattern, $string);
print_r($matches); |
|
0 |
0 |
1 |
0439 |
What is PDO::query() equivalent to? |
|
|
0 |
0 |
1 |
0440 |
Which HTTP status code asks a user to provide credentials? |
|
|
0 |
0 |
1 |
0441 |
What would be the output of this script? |
ob_start();
echo "dreaming";
$ob = ob_get_contents();
echo strlen($ob);
ob_flush(); |
|
0 |
0 |
1 |
0442 |
What does status code 403 indicate? |
|
|
0 |
0 |
1 |
0443 |
What is the output of the following code? |
$a = "a, b,c, d, e f, g";
$b = array_merge(explode(', ', $a), array("a", "b"));
echo count($b); |
|
0 |
0 |
1 |
0444 |
What is the output of this line of code? |
<?= 8 + 0x8 + 80 + 0x80; ?> |
|
0 |
0 |
1 |
0445 |
Which of the following functions would be a valid way to create an array containing items from three existing arrays? |
|
|
0 |
0 |
1 |
0446 |
What is the output of the following line of code? |
echo "4" + 05 + 011 + ord('a'); |
|
0 |
0 |
1 |
0447 |
What is the output of the following? |
$a = 7;
$b = 4;
function b($a, $b) {
global $a, $b;
$a += 7;
$a++;
$b += $a;
return true;
}
echo $b, $a; |
|
0 |
0 |
1 |
0448 |
Which of the following are configuration settings for PHP? (choose two) |
|
|
0 |
0 |
1 |
0449 |
Is the following valid PHP code? |
<php>
echo 'There's a worm in my apple';
</php> |
|
0 |
0 |
1 |
0450 |
What is the output of: |
$a = "0";
echo strlen($a);
echo empty($a) ? $a : 5;
echo $a ?: 5; |
|
0 |
0 |
1 |
0451 |
What would happen when the following code was run? |
define('Tree', 'oak');
echo 'This tree is: ' . tree; |
|
0 |
0 |
1 |
0452 |
Which of the following are valid constant names? (Choose three) |
|
|
0 |
0 |
1 |
0453 |
What is the output of the following code? |
$a = 42 & 05 + 17;
echo $a; |
|
0 |
0 |
1 |
0454 |
What will the output of the following code be? |
$a = range(3,9);
foreach ($a as $b) {
switch($b) {
case 3:
$b = 7;
case 7:
$b = 3;
default:
// do nothing
}
}
echo implode('-',$a); |
|
0 |
0 |
1 |
0455 |
What is the output of (Assuming you are running in PHP 7.1): |
$a = 10;
echo strlen($a) . count($a);
do {
echo $a . "elephpant ";
$a++;
} while($a <= 1); |
|
0 |
0 |
1 |
0456 |
What is the output of this code: |
function c($a, $b = 1, $c) {
return array($c, $a, $b);
}
list($a, $b, $c) = c(0,0,0);
echo $b; |
|
0 |
0 |
1 |
0457 |
What is the output of the following code: |
function a($a) {
echo $a . "&";
}
function b($a) {
echo "-" . $a;
}
$a = "!";
$b = &$a;
echo a(b($b)); |
|
0 |
0 |
1 |
0458 |
Which of the following are superglobals in PHP? (choose three) |
|
|
0 |
0 |
1 |
0459 |
Which of the following statements are true when applied to a Registry pattern? (choose two) |
|
|
0 |
0 |
1 |
0460 |
Is this statement true or false? "Methods declared as static must be called statically" |
|
|
0 |
0 |
1 |
0461 |
What is the output of this code? |
$wish_list = array(
1 => "Romeo and Juliet",
4 => "Bad Science",
2 => "To Kill A Mockingbird"
);
print_r(sort($wish_list)); |
|
0 |
0 |
1 |
0462 |
ArrayAccess is an example of a: |
|
|
0 |
0 |
1 |
0463 |
Using the notation self::$property refers to: |
|
|
0 |
0 |
1 |
0464 |
Which of the following is a valid namespace operator in PHP? |
|
|
0 |
0 |
1 |
0465 |
What is the output of the following code? |
function print_conditional() {
static $x;
if ($x++ == 1) echo "many";
echo "good";
echo "things";
return $x;
}
$x = 1;
print_conditional();
$x++;
print_conditional(); |
|
0 |
0 |
1 |
0466 |
What does the html_errors configuration directive do? |
|
|
0 |
0 |
1 |
0467 |
What is the output of the following code? |
$a = 1;
function calculate() {
global $a;
$a += 7;
$a = $a * 043;
return --$a;
}
echo $a; |
|
0 |
0 |
1 |
0468 |
What is the output of the following code? |
function format(&$item) {
$item = strtoupper($item) . '.';
return $item;
}
$shopping = array("fish", "bread", "eggs", "jelly", "apples");
array_walk($shopping, "format");
$shopping = sort($shopping);
echo $shopping[1]; |
|
0 |
0 |
1 |
0469 |
What is the output of the following code? |
class Content {
public function publish() {
$this->published = true;
$this->article();
return true;
}
protected function article() {
echo "<i>Article:</i>";
}
}
class Article extends Content
{
public function article() {
echo "<i>Post:</i>";
}
}
$post = new Article();
echo $post->publish(); |
|
0 |
0 |
1 |
0470 |
Given the following code: |
Interface Verifiable {
public function verify();
}
Class Cheque {
public function verify() {
return true;
}
}
Class CurrencyCheque extends Cheque implements Verifiable
{
// interesting stuff happens
}
$obj = new CurrencyCheque(); |
What happens when we instantiate a CurrencyCheque object? |
0 |
0 |
1 |
0471 |
What is the output of the following code? |
if(strcmp("hi", "HI")) echo "hello";
elseif(strcasecmp("hi","HI")) echo "world";
else throw new Exception("HI"); |
|
0 |
0 |
1 |
0472 |
How can you recover the original information from this string? |
a:4:{i:2;s:3:"foo";i:3;s:4:"spot";i:4;s:6:"stripe";s:3:"bar";i:64;} |
|
0 |
0 |
1 |
0473 |
Which of the following are true (choose three)? |
|
|
0 |
0 |
1 |
0474 |
What is the output of the following? |
echo chr((ord('a') + ord('A'))/2); |
|
0 |
0 |
1 |
0475 |
How would you efficiently extract data from a csv file which is several gigabytes in size? |
|
|
0 |
0 |
1 |
0476 |
Which of the following would you use to validate incoming data from a web form? (choose three)? |
|
|
0 |
0 |
1 |
0477 |
Which of the following php configuration directives were deprecated in PHP 5.3 (tick as many as apply)? |
|
|
0 |
0 |
1 |
0478 |
What is the output of the following? |
$a = 0xf2 + 0x09;
$b = $a >> 3;
echo $b; |
|
0 |
0 |
1 |
0479 |
Which of the following would allow you to send a POST request to a remote resource via file_get_contents()? |
|
|
0 |
0 |
1 |
0480 |
Which function would you use to re-order an array by its keys? |
|
|
0 |
0 |
1 |
0481 |
What does the chr() function do? |
|
|
0 |
0 |
1 |
0482 |
Given this code sample: |
interface A {}
class C {}
class B extends C {}
class E extends C implements A {}
class D extends E{}
$b = new B();
$e = new E();
$c = new C();
$a = new B();
$d = new D(); |
Which of the following statements are true? |
0 |
0 |
1 |
0483 |
Which of the following session save handlers are available by default in PHP? (choose 3) |
|
|
0 |
0 |
1 |
0484 |
The Active Record design pattern is used for which of the following? |
|
|
0 |
0 |
1 |
0485 |
With a single existing cookie set for this domain with the key "theme" and the value "green", what does the following code output? |
print_r($_COOKIE);
setcookie('theme', NULL, time() - 3600);
print_r($_COOKIE);
unset($_COOKIE);
print_r($_COOKIE); |
|
0 |
0 |
1 |
0486 |
What does the following code output? |
$i = function($j) {
$i = $j + 4;
return $i++;
};
$j = 6;
echo $i($j); |
|
0 |
0 |
1 |
0487 |
What is the output of the following code? |
function swings(&$park) {
$park++;
$park = roundabout($park);
}
function roundabout($park) {
$park *= 2;
}
$park = 17;
echo swings($park); |
|
0 |
0 |
1 |
0488 |
What is the output of the following code? |
function print_conditional($x) {
if ($x++ == 1) echo "none";
echo "one";
echo "none";
return $x;
}
$x = 1;
print_conditional($x);
$x++;
print_conditional($x); |
|
0 |
0 |
1 |
0489 |
Which object method is automatically called when an object is cloned? |
|
|
0 |
0 |
1 |
0490 |
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;
}
} |
|
0 |
0 |
1 |
0491 |
What is the output of the following code? |
$s = "This sentence contains many words";
$r = explode(' ', ucfirst($s));
sort($r);
echo implode(',', $r); |
|
0 |
0 |
1 |
0492 |
Given a class called SoapFunctions and a working WSDL for the methods in that class, what needs to be added to the code below to serve those methods over SOAP? |
require("SoapFunctions.php");
$s = new SoapServer($wsdl);
$s->handle(); |
|
0 |
0 |
1 |
0493 |
Which of the following is a magic method in PHP? |
|
|
0 |
0 |
1 |
0494 |
Which function would transform the string "excellent PHP functions" into the string "Excellent PHP Functions"? |
|
|
0 |
0 |
1 |
0495 |
Which of the following would offer protection against an SQL injection attack? (choose two) |
|
|
0 |
0 |
1 |
0496 |
What is the output of the following code? |
class M {
public function identify() {
echo self::myName();
}
public function myName() {
return "Mike";
}
}
class N extends M {
public function myName() {
return "November";
}
}
function m(N $n) {
$n->identify();
}
$m = new N();
m($m); |
|
0 |
0 |
1 |
0497 |
What is the output of the following code? |
$a = "Apple";
echo <<<'A'
pass me that $a
A; |
|
0 |
0 |
1 |
0498 |
How would you change a SimpleXMLElement object into a DOMElement? (choose two) |
|
|
0 |
0 |
1 |
0499 |
What is the preferred way of writing the value 25 to a session variable called age? |
|
|
0 |
0 |
1 |
0500 |
By default PHP stores its sessions on the web server's filesystem. What function is used to tell PHP to use your custom session storage handler? |
|
|
0 |
0 |
1 |
0501 |
What is the output of this script the third time it is loaded in a browser by the same user? |
session_start();
if (!array_key_exists('counter', $_SESSION)) {
$_SESSION['counter'] = 0;
} else {
$_SESSION['counter']++;
}
session_regenerate_id();
echo $_SESSION['counter']; |
|
0 |
0 |
1 |
0502 |
Session fixation - a commonly-used session-based attack - can be prevented simply by giving a user a new session ID whenever they obtain a new level of permission on a site (for instance, after they successfully login). Which PHP function is used to change the ID for an active session? |
|
|
0 |
0 |
1 |
0503 |
Which of the following statements best describes session fixation? |
|
|
0 |
0 |
1 |
0504 |
How do you initiate the use of sessions in PHP? |
|
|
0 |
0 |
1 |
0505 |
What is the result of the following code? |
echo (new anonymousclass {
function foo() {
return ['5', '7', '1'];
}
})->foo()[0][0]; |
|
0 |
0 |
1 |
0506 |
What is the result of the following code? |
function foo(string $a, ?string $b) : ?int {
return $b ? $a <=> $b : null;
}
echo foo('PHP', 7); |
|
0 |
0 |
1 |
0507 |
What is the correct way to add 1 to the $count variable? |
|
|
0 |
0 |
1 |
0508 |
If a function expects a parameter of type iterable, what can you do to send an object? |
|
|
0 |
0 |
1 |
0509 |
Which of the following is not a valid fopen() access mode: |
|
|
0 |
0 |
1 |
0510 |
Consider the following String: |
$string = "John\tMark\nTed\tLarry"; |
Which of the following functions would best parse the string above by the tab (\t) and newline (\n) characters? |
0 |
0 |
1 |
0511 |
What is the output of? |
function apple($apples = 4) {
$apples = $apples / 2;
return $apples;
}
$apples = 10;
apple($apples);
echo $apples; |
|
0 |
0 |
1 |
0512 |
What is the output of? |
function apple(&$apples = 4) {
$apples = $apples / 2;
return $apples;
}
$apples = 10;
apple($apples);
echo $apples; |
|
0 |
0 |
1 |
0513 |
Which of the following functions are used with the internal array pointer to accomplish an action? |
|
|
0 |
0 |
1 |
0514 |
What three special methods can be used to perform special logic in the event a particular accessed method or member variable is not found? |
|
|
0 |
0 |
1 |
0515 |
What would you replace at line 2 // ??? with, below, to make the string 'Hello, World!' be displayed? |
function myfunction() {
// ???
print $string;
}
myfunction("Hello, World!"); |
|
0 |
0 |
1 |
0516 |
Consider the following code snippet: |
$query = "INSERT INTO mytable (myinteger, mydouble, myblob, myvarchar)
VALUES (?, ?, ?, ?)";
$statement = mysqli_prepare($link, $query);
if (!$statement) {
die(mysqli_error($link));
}
/* The variables being bound to by MySQLi don't need to exist prior to binding */
mysqli_bind_param($statement, "idbs", $myinteger, $mydouble, $myblob, $myvarchar);
/* ???????????? */
/* execute the query, using the variables as defined. */
if (!mysqli_execute($statement)) {
die(mysqli_error($link));
} |
Assuming this snippet is a smaller part of a correctly written script, what actions must occur in place of the ????? in the above code snippet to insert a row with the following values: 10, 20.2, foo, string ? |
0 |
0 |
1 |
0517 |
What is the output of the following code block? |
$array = array(1 => 0, 2, 3, 4);
array_splice($array, 3, count($array), array_merge(array('x'), array_slice($array, 3)));
var_dump($array); |
|
0 |
0 |
1 |
0518 |
In PHP the error control operator is ___ |
|
|
0 |
0 |
1 |
0519 |
When opening a file in writing mode using the FTP handler, what must be done so that the file will still be written to the server in the event it previously exists? |
|
|
0 |
0 |
1 |
0520 |
Which of the following are examples of the new engine executor models available in PHP 5? |
|
|
0 |
0 |
1 |
0521 |
What is the output of the following? |
function x10(&$number) {
$number *= 10;
}
$count = 5;
x10($count);
echo $count; |
|
0 |
0 |
1 |
0522 |
What is the output of the following? |
function 1dotEach($n){
if ($n > 0) {
1dotEach(--$n);
echo ".";
} else {
return $n;
}
}
1dotEach(4); |
|
0 |
0 |
1 |
0523 |
Consider the following code: |
session_start();
if(!empty($_REQUEST['id']) && !empty($_REQUEST['quantity'])) {
$id = scrub_id($_REQUEST['id']);
$quantity = scrub_quantity($_REQUEST['quantity'])
$_SESSION['cart'][] = array('id' => $id, 'quantity' => $quantity)
}
/* .... */ |
What potential security hole would this code snippet produce? |
0 |
0 |
1 |
0524 |
When working with a database, which of the following can be used to mitigate the possibility of exposing your database credientials to a malicious user? |
|
|
0 |
0 |
1 |
0525 |
What is the best way to ensure the distinction between filtered / trusted and unfiltered / untrusted data? |
|
|
0 |
0 |
1 |
0526 |
Consider the following HTML fragement: |
<select name="?????" multiple>
<option value="1">Item #1</option>
<!-- ... more options ... -->
</select> |
Which of the following name attributes should be used to capture all of the data from the user in PHP? |
0 |
0 |
1 |
0527 |
Which php.ini directive should be disabled to prevent the execution of a remote PHP script via an include or require construct? |
|
|
0 |
0 |
1 |
0528 |
The ___ constant in a CLI script is an automatically provided file resource representing standard input of the terminal. |
|
|
0 |
0 |
1 |
0529 |
Consider the following script: |
$oranges = 10;
$apples = 5;
$string = "I have %d apples and %d oranges";
/* ??????? */ |
What could be placed in place of ?????? to output the string: |
0 |
0 |
1 |
0530 |
___ can be used to add additional functionality to a stream, such as implementation of a specific protocol on top of a normal PHP stream implementation. |
|
|
0 |
0 |
1 |
0531 |
What is the output of the following? |
class C {
public $x = 1;
function __construct() {
++$this->x;
}
function __invoke() {
return ++$this->x;
}
function __toString() {
return (string)--$this->x;
}
}
$obj = new C();
echo $obj(); |
|
0 |
0 |
1 |
0532 |
When an object is serialized, which method will be called, automatically, providing your object with an opportunity to close any resources or otherwise prepare to be serialized? |
|
|
0 |
0 |
1 |
0533 |
Consider the following script: |
$dom = new DOMDOcument();
$dom->load('0138.xml');
foreach($dom->documentElement->childNodes as $child) {
if(($child->nodeType == XML_ELEMENT_NODE) && $child->nodeName == "item") {
foreach($child->childNodes as $item) {
if(($item->nodeType == XML_ELEMENT_NODE) && ($item->nodeName == "title")) {
print "{$item->firstChild->data}\n";
}
}
}
} |
Assuming the referenced XML document exists and matches the parsing logic, what should be displayed when this script is executed? |
0 |
0 |
1 |
0534 |
When is it acceptable to store sensitive information in an HTTP cookie? |
|
|
0 |
0 |
1 |
0535 |
Given the following XML document in a SimpleXML object: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>XML Example</title>
</head>
<body>
<p>
Moved to <<a href="http://example.org/">http://www.example.org/</a>.>
<br/>
</p>
</body>
</html> |
Select the proper statement below which will display the HREF attribute of the anchor tag. |
0 |
0 |
1 |
0536 |
To ensure that a given object has a particular set of methods, you must provide a method list in the form of an ____ and then attach it as part of your class using the ____ keyword. |
|
|
0 |
0 |
1 |
0537 |
Which of the following comparisons will evaluate to true? |
var_dump(
't' == t, // Notice
1 === "1time",
"top" == 0,
"top" === 0,
1 == "1time"
); |
|
0 |
0 |
1 |
0538 |
What is the output of the following? |
$a = 20;
function myfunction($b) {
global $a, $c;
$a = 30;
return $c = ($b + $a);
}
// 140 = (40 + 30) + 70
print myfunction(40) + $c; |
|
0 |
0 |
1 |
0539 |
What is the correct way to create a function in PHP? |
|
|
0 |
0 |
1 |
0540 |
Identify the best approach to compare two variables in a binary-safe fashion. |
|
|
0 |
0 |
1 |
0541 |
How can the following code be re-written from PHP 4 to PHP 5/7? |
if (get_class($myObj) == "MyClass") {
// Do something
} |
|
0 |
0 |
1 |
0542 |
What is the output of the following code? |
function oranges(&$oranges = 17) {
$oranges .= 1;
}
$apples = 5;
oranges($apples);
echo $apples++; |
|
0 |
0 |
1 |
0543 |
Which of the following is not a valid default stream wrapper for PHP 5, assuming OpenSSL is enabled? |
|
|
0 |
0 |
1 |
0544 |
Removing undesired markup tags from input can best be done using which function? |
|
|
0 |
0 |
1 |
0545 |
How do you declare a function to accept a variable (unknown) number of arguments in PHP 7? |
|
|
0 |
0 |
1 |
0546 |
What is the output of the following? |
function a($number) {
return (b($number) * $number);
}
function b(&$number) {
return ++$number;
}
echo a(5); |
|
0 |
0 |
1 |
0547 |
What is the output of the following? |
function a(&$apples) {
$apples++;
}
$oranges = 5;
$apples = 5;
a($oranges);
echo "I have $apples apples and $oranges oranges"; |
|
0 |
0 |
1 |
0548 |
Which of the following extensions are no longer part of PHP 5 and have been moved to PECL? |
|
|
0 |
0 |
1 |
0549 |
What is the output of the following PHP code? |
define('FOO', 10);
$array = array(10 => FOO, "FOO" => 20);
print $array[$array[FOO]] * $array["FOO"]; |
|
0 |
0 |
1 |
0550 |
The following code snippet displays what for the resultant array? |
$a = array(1 => 0, 3 => 2, 4 => 6);
$b = array(3 => 1, 4 => 3, 6 => 4);
print_r(array_intersect($a, $b)); |
|
0 |
0 |
1 |
0551 |
When connecting to a database using PDO, what must be done to ensure that database credentials are not compromised if the connection were to fail? |
|
|
0 |
0 |
1 |
0552 |
Which of the following functions will sort an array in ascending order by value, while preserving key associations? |
|
|
0 |
0 |
1 |
0553 |
Which functions would be needed to translate the following string: |
I love PHP 5
|
to the following? |
0 |
0 |
1 |
0554 |
What does the following PHP script accomplish? |
$dom = new DomDocument();
$dom->load('test.xml');
$body = $dom->documentElement->getElementsByTagName('body')->item(0);
echo $body->getAttributeNode('background')->value. "\n"; |
|
0 |
0 |
1 |
0555 |
Consider the following code: |
header("Location: {$_GET['url']}"); |
Which of the following values of $_GET['url'] would cause session fixation? |
0 |
0 |
1 |
0556 |
What is the output of the following script? |
function x10(&$number) {
$number *= 10;
}
$count = 5;
x10($count);
echo $count; |
|
0 |
0 |
1 |
0557 |
Which of the following is not a valid PDO DSN? |
|
|
0 |
0 |
1 |
0558 |
Consider the following code block: |
function &myFunction() {
$string = "MyString";
var_dump($string);
return ($undefined);
}
for ($i = 0; $i < 10; $i++) {
$retval = myFunction();
} |
This code block's behavior has changed between PHP 4 and PHP 5. Why? |
0 |
0 |
1 |
0559 |
SimpleXML objects can be created from what types of data sources? |
|
|
0 |
0 |
1 |
0560 |
Consider the following script: |
try {
$dbh = new PDO("sqlite::memory:");
} catch(PDOException $e) {
print $e->getMessage();
}
$dbh->query("CREATE TABLE foo(id INT)");
$stmt = $dbh->prepare("INSERT INTO foo VALUES(:value)");
$value = null;
$data = array(1,2,3,4,5);
$stmt->bindParam(":value", $value);
/* ?????? */
try {
foreach($data as $value) {
/* ????? */
}
} catch(PDOException $e) {
/* ??????? */
}
/* ?????? */ |
What lines of code need to go into the missing places above in order for this script to function properly and insert the data into the database safely? |
0 |
0 |
1 |
0561 |
Using flock() to lock a stream is only assured to work under what circumstances? |
|
|
0 |
0 |
1 |
0562 |
To destroy a PHP session completely, one must which of the following? |
|
|
0 |
0 |
1 |
0563 |
What is the output of the following code block? |
$a = "The quick brown fox jumped over the lazy dog.";
$b = array_map("strtoupper", explode(" ", $a));
foreach ($b as $value) {
print "$value ";
} |
|
0 |
0 |
1 |
0564 |
What does the following code will print in PHP 7? |
$a = [0, 1, 2];
foreach($a as $val) {
var_dump(current($a));
} |
|
0 |
0 |
1 |
0565 |
What should go in the ??????? assignment below to create a Zlib-compressed file foo.gz with a compression level of 9 ? |
$file = '????????';
$fr = fopen($file, 'wb9');
fwrite($fr, $data);
fclose($fr); |
|
0 |
0 |
1 |
0566 |
Where should indirectly executed PHP scripts (i.e. include files) be stored in the file system? |
|
|
0 |
0 |
1 |
0567 |
What XML technology is used when you mix two different document types in a single XML document? |
|
|
0 |
0 |
1 |
0568 |
Which of the following tags are an acceptable way to begin a PHP Code block(PHP 5.3)? (Choose 3) |
|
|
0 |
0 |
1 |
0569 |
Consider the following script: |
$string = "<b>I like 'PHP' & I think it is \"cool\"</b>";
var_dump(htmlentities($string, ENT_QUOTES));
var_dump(htmlspecialchars($string)); |
In this script, do the two var_dump() calls produce the same string? Why or Why Not? |
0 |
0 |
1 |
0570 |
In PHP 5 you can use the __ operator to ensure that an object is of a particular type. You can also use ___ in the function declaration. |
|
|
0 |
0 |
1 |
0571 |
When working with SimpleXML in PHP 5, the four basic rules on how the XML document is accessed are which of the following? |
|
|
0 |
0 |
1 |
0572 |
How do you declare the return type of a function? |
|
|
0 |
0 |
1 |
0573 |
When running PHP in a shared host environment, what is the major security concern when it comes to session data? |
|
|
0 |
0 |
1 |
0574 |
Which of the following list of potential data sources should be considered trusted? |
|
|
0 |
0 |
1 |
0575 |
Unlike a database such as MySQL, SQLite columns are not explicitly typed. Instead, SQLite catagorizes data into which of the following catagories? |
|
|
0 |
0 |
1 |
0576 |
Given the following array: |
$array = array(1,1,2,3,4,4,5,6,6,6,6,3,2,2,2); |
The fastest way to determine the total number a particular value appears in the array is to use which function? |
0 |
0 |
1 |
0577 |
Type-hinting and the instanceof keyword can be used to check what types of things about variables? |
|
|
0 |
0 |
1 |
0578 |
When writing portable database code using PDO, what is the PDO::ATTR_CASE attribute useful for? |
|
|
0 |
0 |
1 |
0579 |
What does the following code print? |
$a = 'aaaa';
$b = 'bbbb';
echo $a ?? $b ?? 'cccc'; |
|
0 |
0 |
1 |
0580 |
What does the following code print? |
echo 2 <=> 1; |
|
0 |
0 |
1 |
0581 |
To destroy one variable within a PHP session you should use which method in PHP 5? |
|
|
0 |
0 |
1 |
0582 |
What will be the output of the below code? |
$a = "PHP";
$a++;
echo $a; |
|
0 |
0 |
1 |
0583 |
What is the output of the following code: |
$a = '1';
$b = &$a;
$b = "2$b";
echo $a.", ".$b; |
|
0 |
0 |
1 |
0584 |
Which key will not be displayed from the following code block? |
$array = ['a' => 'John', 'b' => 'Coggeshall', 'c' => ['d' => 'John', 'e' => 'Smith']];
function display($item, $key) {
print "$key => $item\n";
}
array_walk_recursive($array, "display"); |
|
0 |
0 |
1 |
0585 |
Consider the following PHP string representing an SQL statement: |
$query = "UPDATE users SET password='$password' WHERE username='$username'"; |
Which of the following values for $username or $password would change the behavior of this query when executed? |
0 |
0 |
1 |
0586 |
What variable reference would go in the spots indcated by ????? in the code segment below? |
$msg = "The Quick Brown Foxed Jumped Over the Lazy Dog";
$state = true;
$retval = "";
for ($i = 0; (isset(?????)); $i++) {
if ($state) {
$retval .= strtolower(?????);
} else {
$retval .= strtoupper(?????);
}
$state = !$state;
}
print $retval; |
|
0 |
0 |
1 |
0587 |
Given the two values below, which of the following possiblities will print 10 foos20 bars? |
$var1 = "10 foos";
$var2 = "20 bars";
print ???????; |
|
0 |
0 |
1 |
0588 |
The __ keyword is used to indicate an incomplete class or method, which must be further extended and/or implemented in order to be used. |
|
|
0 |
0 |
1 |
0589 |
What combination of boolean values for $a, $b, $c, and $d will result in the variable $number being equal to 3? |
$a = null;
$b = null;
$c = null;
$d = null;
if($a && !$b) {
if(!!$c && !$d) {
if($d && ($a || $c)) {
if(!$d && $b) {
$number = 1;
} else {
$number = 2;
}
} else {
$number = 3;
}
} else {
$number = 4;
}
} else {
$number = 5;
} |
|
0 |
0 |
1 |
0590 |
One can ensure that headers can always be sent from a PHP script by doing what? |
|
|
0 |
0 |
1 |
0591 |
Which of the following methods are used to fetch data from a PDO Statement? |
|
|
0 |
0 |
1 |
0592 |
Which string does the following PCRE regular expression match? |
$regex = "/^([a-z]{5})[1-5]+([a-z]+)/"; |
|
0 |
0 |
1 |
0593 |
Which of the following are valid PHP variables? (Choose 3) |
|
|
0 |
0 |
1 |
0594 |
What is the best way to ensure that a user-defined function is always passed an object as its single parameter? |
|
|
0 |
0 |
1 |
0595 |
Setting a cookie on the client in PHP 5 can be best accomplished by: |
|
|
0 |
0 |
1 |
0596 |
Which statement will return the third parameter passed to a function? |
|
|
0 |
0 |
1 |
0597 |
What is the output of the following function? |
function &find_variable(&$one, &$two, &$three) {
if ($one > 95 && $one < 100) return $one;
if ($two > 10 && $two < 20) return $two;
if ($three > 1 && $three < 100) return $three;
}
$one = 90;
$two = 60;
$three = 89;
$var = &find_variable($one, $two, $three);
$var++;
echo "$one - $two - $three"; |
|
0 |
0 |
1 |
0598 |
If you would like to change the session ID generation function, which of the following is the best approach for PHP 5? |
|
|
0 |
0 |
1 |
0599 |
Which of the following functions allow you to introspect the call stack during execution of a PHP script? |
|
|
0 |
0 |
1 |
0600 |
The ____ construct is particularly useful to assign your own variable names to values within an array. |
|
|
0 |
0 |
1 |
0601 |
What is the best measure one can take to prevent a cross-site request forgery (CSRF)? |
|
|
0 |
0 |
1 |
0602 |
What is the output of the following code? |
$string = "14302";
$string[$string[2]] = "4";
print $string; |
|
0 |
0 |
1 |
0603 |
Which of the following is the best way to split a string on the "-=-" pattern? |
$string = 'apple-=-banana-=-orange'; |
|
0 |
0 |
1 |
0604 |
What is the output of the following code? |
function oranges($oranges = 17) {
$oranges .= 1;
}
$apples = 5;
oranges($apples);
echo ++$apples; |
|
0 |
0 |
1 |
0605 |
Which of the following is not valid syntax for creating a new array key? |
|
|
0 |
0 |
1 |
0606 |
How do you define an array in PHP7? |
|
|
0 |
0 |
1 |
0607 |
What would go in place of ?????? below to make this script execute without a fatal error? |
$a = 1;
$b = 0;
/* ?????? */
$c = $a / $b; |
|
0 |
0 |
1 |
0608 |
What is wrong with the following code snippet? Assume default configuration values apply. |
$fp = fsockopen('www.php.net', 80);
fwrite($fp, "GET / HTTP/1.0\r\nHost: www.php.net\r\n");
$data = fread($fp, 8192); |
|
0 |
0 |
1 |
0609 |
Which from the following list is not an appropriate use of an array? |
|
|
0 |
0 |
1 |
0610 |
What is wrong with the following code? |
function duplicate($obj) {
$newObj = $obj;
return $newObj;
}
$a = new MyClass();
$a_copy = duplicate($a);
$a->setValue(10);
$a_copy->setValue(20); |
|
0 |
0 |
1 |
0611 |
Which of the following functions could be used to break a string into an array? |
|
|
0 |
0 |
1 |
0612 |
Consider the following script: |
function func(&$arraykey) {
return $arraykey; // function returns by value!
}
$array = array('a', 'b', 'c');
foreach (array_keys($array) as $key) {
$y = &func($array[$key]);
$z[] =& $y;
}
var_dump($z); |
This code has changed behavior in PHP 5. Identify the output of this script as it would have been in PHP 4, as well as the new behavior in PHP 5. |
0 |
0 |
1 |
0613 |
Given the string: |
$var = "john@php.net"; |
Which of the following will extract the TLD (top level domain) of ".net" from the string? |
0 |
0 |
1 |
0614 |
What is the result of the following code snippet? |
$array = array(
'a' => 'John',
'b' => 'Coggeshall',
'c' => array(
'd' => 'John',
'e' => 'Smith'
)
);
function something($array) {
extract($array);
return $c['e'];
}
print something($array); |
|
0 |
0 |
1 |
0615 |
How does one create a cookie which will exist only until the browser session is terminated? |
|
|
0 |
0 |
1 |
0616 |
If you would like to store your session in the database, you would do which of the following? |
|
|
0 |
0 |
1 |
0617 |
When writing CLI scripts it is often useful to access the standard streams available to the operating system such as standard input/output and error.
How does one access these streams in PHP 5/7? |
|
|
0 |
0 |
1 |
0618 |
What is the output of the following? |
function _1dotEach($n) {
if ($n > 0) {
_1dotEach(--$n);
echo ".";
} else {
return $n;
}
}
_1dotEach(4); |
|
0 |
0 |
1 |
0619 |
The MVC pattern in Web development involves which of the following components? |
|
|
0 |
0 |
1 |
0620 |
For an arbitrary string $mystring, which of the following checks will correctly determine if the string PHP exists within it? |
|
|
0 |
0 |
1 |
0621 |
Consider the following code snippet: |
$link = mysqli_connect("hostname", "username", "password");
if (!$link) {
/* $error = ??????; */
die("Could not connect to the database: $error");
} |
What would go in place of the ???? above for this script to function properly? |
0 |
0 |
1 |
0622 |
During an HTTP authentication, how does one determine the username and password provided by the browser? |
|
|
0 |
0 |
1 |
0623 |
What is the output of the following code? |
class MyException extends Exception {}
class AnotherException extends MyException {}
class Foo {
public function something() {
throw new AnotherException();
}
public function somethingElse() {
throw new MyException();
}
}
$a = new Foo();
try {
try {
$a->something();
} catch(AnotherException $e) {
$a->somethingElse();
} catch(MyException $e) {
print "Caught Exception";
}
} catch(Exception $e) {
print "Didn't catch the Exception!";
} |
|
0 |
0 |
1 |
0624 |
A fingerprint of a string can be determined using which of the following? |
|
|
0 |
0 |
1 |
0625 |
What is the best approach for converting this string: |
$string = "a=10&b[]=20&c=30&d=40+50";
// Into this array?
array(- [ ] {
["a"]=>
string(- [ ] "10"
["b"]=>
array(- [ ] {
[0]=>
string(- [ ] "20"
}
["c"]=>
string(- [ ] "30"
["d"]=>
string(- [ ] "40 50"
} |
|
0 |
0 |
1 |
0626 |
Setting a HTTP cookie on the client which is not URL-encoded is done how in PHP 5? |
|
|
0 |
0 |
1 |
0627 |
Event-based XML parsing is an example of which parsing model? |
|
|
0 |
0 |
1 |
0628 |
Which of the following SQL statements will improve SQLite write performance? |
|
|
0 |
0 |
1 |
0629 |
Consider the following code snippet: |
$query = "SELECT first, last, phone
FROM contacts
WHERE first LIKE 'John%'";
$statement = mysqli_prepare($link, $query);
mysqli_execute($statement);
/* ???? */
while (($result = mysqli_stmt_fetch($statement))) {
print "Name: $first $last\n";
print "Phone: $phone\n\n";
} |
Assuming this code snippet is part of a larger correct application, what must be done in place of the ???? above for the correct output to be displayed? |
0 |
0 |
1 |
0630 |
When comparing two strings, which of the following is acceptable? |
|
|
0 |
0 |
1 |
0631 |
Consider the following simple PHP script: |
$dom = new DomDocument();
$dom->load('test.xml');
$xpath = new DomXPath($dom);
$nodes = $xpath->query(???????, $dom->documentElement);
echo $nodes->item(0)->getAttributeNode('bgcolor')->value . "\n"; |
What XPath query should go in the ?????? above to display the "bgcolor" attribute of the first "body" node in the XML document? |
0 |
0 |
1 |
0632 |
What is the output of the following script? |
class ClassOne {
protected $a = 10;
public function changeValue($b) {
$this->a = $b;
}
}
class ClassTwo extends ClassOne {
protected $b = 10;
public function changeValue($b) {
$this->b = 10;
parent::changeValue($this->a + $this->b);
}
public function displayValues() {
print "a: {$this->a}, b: {$this->b}\n";
}
}
$obj = new ClassTwo();
$obj->changeValue(20);
$obj->changeValue(10);
$obj->displayValues(); |
|
0 |
0 |
1 |
0633 |
Is this code valid only in PHP 7, in PHP 5, or both? |
function myfunction(&$myvalue = null) {
/* ... */
} |
|
0 |
0 |
1 |
0634 |
SQL Injections can be best prevented using which of the following database technologies? |
|
|
0 |
0 |
1 |
0635 |
When executing system commands from PHP, what should one do to keep applications secure? |
|
|
0 |
0 |
1 |
0636 |
When using a function such as strip_tags, are markup-based attacks still possible? |
|
|
0 |
0 |
1 |
0637 |
What is the output of the following? |
$a = 010;
$b = 0xA;
$c = 2;
print $a + $b + $c; |
|
0 |
0 |
1 |
0638 |
How do you group in a single USE statement multiple classes from the same namespace? |
|
|
0 |
0 |
1 |
0639 |
What is the difference between the include and require language constructs? |
|
|
0 |
0 |
1 |
0640 |
What is the output of the following? |
$a = 0b010;
$b = 0xA;
$c = 2;
print $a + $b + $c; |
|
0 |
0 |
1 |
0641 |
When attempting to prevent a cross-site scripting (XSS) attack, which of the following is most important? |
|
|
0 |
0 |
1 |
0642 |
What does the following code print? |
function gen() {
yield 1;
yield 2;
return 13;
}
foreach (gen() as $item) {
echo $item;
} |
|
0 |
0 |
1 |
0643 |
When implementing a permissions system for your Web site, what should always be done with regards to the session? |
|
|
0 |
0 |
1 |
0644 |
What is a valid body for a function that has void as return type? |
function test(): void // ??? |
|
0 |
0 |
1 |
0645 |
When migrating the following code from PHP 4 to PHP 5, what should be changed? |
class MyClass {
function MyClass($param) {
# Do something with $param
$this->_doSomething($param);
}
// Private method to MyClass
function _doSomething($param) {
# Do something with $param
}
}
class AnotherClass extends MyClass {
var $param = "foo";
function AnotherClass() {
parent::MyClass($this->param);
}
} |
|
0 |
0 |
1 |
0646 |
Which of the following functions is used to determine if a given stream is blocking or not? |
|
|
0 |
0 |
1 |
0647 |
Which two internal PHP interfaces provide functionality which allow you to treat an object like an array? |
|
|
0 |
0 |
1 |
0648 |
Which of the following php.ini directives should be disabled to improve the outward security of your application? |
|
|
0 |
0 |
1 |
0649 |
Which of the following cases are cases when you should use transactions? |
|
|
0 |
0 |
1 |
0650 |
Consider the following function: |
function redirect($url) {
// Check to make sure we haven't already sent
// the header:
if(/*?????*/) {
header("Location: $url");
}
} |
What conditional should replace the ????? above? |
0 |
0 |
1 |
0651 |
In PHP7 objects are passed by reference to a function when? |
|
|
0 |
0 |
1 |
0652 |
What should go in the missing line ????? below to produce the output shown? |
$array_one = array(1,2,3,4,5);
$array_two = array('A', 'B', 'C', 'D', 'E');
/* ????? */
print_r($array_three);
/* Result:
Array
(
[5] => A
[4] => B
[3] => C
[2] => D
[1] => E
)
*/ |
|
0 |
0 |
1 |
0653 |
What is the output of the following code? |
function byReference(&$variable = 0){
echo ++$variable;
}
byReference();
byReference(); |
|
0 |
0 |
1 |
0654 |
Which of the following aspects of the MVC pattern is used in conjunction with the database? |
|
|
0 |
0 |
1 |
0655 |
PHP 5 supports which of the following XML parsing methods? |
|
|
0 |
0 |
1 |
0656 |
Creating new nodes in XML documents using PHP can be done using which XML/PHP 5 technologies? |
|
|
0 |
0 |
1 |
0657 |
Which function is best suited for removing markup tags from a string? |
|
|
0 |
0 |
1 |
0658 |
If regular expressions must be used, in general which type of regular expression functions available to PHP is preferred for performance reasons? |
|
|
0 |
0 |
1 |
0659 |
Which function would you use to add an element to the beginning of an array? |
|
|
0 |
0 |
1 |
0660 |
What is the output of the following? |
function l(&$number) {
$number *= 10;
return ($number - 5);
}
$number = 10;
$number = L($number);
echo $number; |
|
0 |
0 |
1 |
0661 |
Which of the following are NOT valid ways to embed a variable into a string? |
|
|
0 |
0 |
1 |
0662 |
When uploading a file using HTTP, which variable can be used to locate the file on PHP's local filesystem? |
|
|
0 |
0 |
1 |
0663 |
What is the best way to ensure that a user-defined function is always passed an object as its single parameter? |
|
|
0 |
0 |
1 |
0664 |
Consider the following PHP script fragment: |
$title = $dom->createElement('title');
$node = ?????
$title->appendChild($node);
$head->appendChild($title); |
What should ????? be replaced with to add a <title> node with the value of Hello, World! |
0 |
0 |
1 |
0665 |
What is the primary benefit of a SAX-based XML parser compared to DOM? |
|
|
0 |
0 |
1 |
0666 |
When checking to see if two variables contain the same instance of an object, which of the following comparisons should be used? |
|
|
0 |
0 |
1 |
0667 |
What does the following code output? |
$i = 016;
echo $i / 2; |
|
0 |
0 |
1 |
0668 |
What are the values of $a in $obj_one and $obj_two when this script is executed? |
class myClass {
private $a;
public function __construct() {
$this->a = 10;
}
public function printValue() {
print "{$this->a},";
}
public function changeValue($val, $obj = null) {
if (is_null($obj)) {
$this->a = $val;
} else {
$obj->a = $val;
}
}
public function getValue() {
return $this->a;
}
}
$obj_one = new myClass();
$obj_two = new myClass();
$obj_one->changeValue(20, $obj_two);
$obj_two->changeValue($obj_two->getValue(), $obj_one);
$obj_two->printValue();
$obj_one->printValue(); |
|
0 |
0 |
1 |
0669 |
What is the output of the following PHP script? |
$a = 1;
$b = 2.5;
$c = 0xFF;
$d = $b + $c;
$e = $d * $b;
$f = ($d + $e) % $a;
print ($f + $e); |
|
0 |
0 |
1 |
0670 |
If you wanted a variable containing the letters A through Z, that allowed you to access each letter independently, which of the following approaches could you use? |
|
|
0 |
0 |
1 |
0671 |
To force a user to redirect to a new URL from within a PHP 5 script, which of the following should be used? |
|
|
0 |
0 |
1 |
0672 |
Which SPL class implements fixed-size storage |
|
|
0 |
0 |
1 |
0673 |
What is the output of the following? |
function a($number) {
return (b($number) * $number);
}
function b(&$number) {
++$number;
}
echo a(5); |
|
0 |
0 |
1 |
0674 |
How can you modify the copy of an object during a clone operation? |
|
|
0 |
0 |
1 |
0675 |
What is the best way to iterate and modify every element of an array using PHP 5/7? |
|
|
0 |
0 |
1 |
0676 |
What is the output of the following? |
function myfunction($b) {
$a = 30;
global $a, $c;
return $c = ($b + $a);
}
print myfunction(40) + $c; |
|
0 |
0 |
1 |
0677 |
Which PCRE regular expression will match the string PhP5-rocks? |
|
|
0 |
0 |
1 |
0678 |
What is the output of the following code? |
$newstring = '';
$string = "111221";
for($i = 0; $i < strlen($string); $i++) {
$current = $string[$i];
$count = 1;
while(isset($string[$i + $count]) && ($string[$i + $count] == $current))
$count++;
$newstring .= "$count{$current}";
$i += $count-1;
}
print $newstring; |
|
0 |
0 |
1 |
0679 |
Assuming every method call below returns an instance of an object, how can the following be re-written in PHP 7? |
$a = new MyClass();
$b = $a->getInstance();
$c = $b->doSomething(); |
|
0 |
0 |
1 |
0680 |
What is the output of the following code? |
function pears(array $pears) {
if (count($pears) > 0) {
echo array_shift($pears);
pears($pears);
}
}
$fruit = ["Anjo", "Bartlet"];
pears($fruit); |
|
0 |
0 |
1 |
0681 |
Consider the following script: |
$dom = new DOMDOcument();
$dom->load('0138.xml');
foreach ($dom->documentElement->childNodes as $child) {
if (($child->nodeType == XML_ELEMENT_NODE) && $child->nodeName == "item") {
foreach ($child->childNodes as $item) {
if (($item->nodeType == XML_ELEMENT_NODE) && ($item->nodeName == "title")) {
print "$item->firstChild->data\n";
}
}
}
} |
Assuming the referenced XML document exists and matches the parsing logic, what should be displayed when this script is executed? |
0 |
0 |
1 |
0682 |
Implementing your own PDO class requires which steps from the list below? |
|
|
0 |
0 |
1 |
0683 |
How can one take advantage of the time waiting for a lock during a stream access, to do other tasks using the following locking code as the base: |
$retval = flock($fr, LOCK_EX); |
|
0 |
0 |
1 |
0684 |
The following is a common XML structure used in service oriented architectures, what does it represent? |
<?xml version="1.0"?>
<methodCall>
<methodName>myMethod</methodName>
<params>
<param>
<value><string>HI!</string></value>
</param>
</params>
</methodCall> |
|
0 |
0 |
1 |
0685 |
Consider the following example XML document: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>XML Example</title>
</head>
<body>
<p>
Moved to <<a href="http://example.org/">http://www.example.org/</a>.>
<br>
</p>
</body>
</html> |
What is wrong with this document, and how can it be corrected? |
0 |
0 |
1 |
0686 |
When embedding PHP into XML documents, what must you ensure is true in order for things to function properly? |
|
|
0 |
0 |
1 |
0687 |
Which of the following functions are part of PHP's internal Iterator interface? |
|
|
0 |
0 |
1 |
0688 |
Why is it important from a security perspective to never display PHP error messages directly to the end user, yet always log them? |
|
|
0 |
0 |
1 |
0689 |
Considering the code below, which of these statements are true? |
ini_set("allow_url_fopen", "1");
$page = file_get_contents("http://www.codepunker.com");
if ($page!=FALSE) {
echo "Successfully fetched website contents";
} else {
echo "An error has occurred";
} |
|
0 |
0 |
1 |
0690 |
What output will this code produce ? |
class Disney {
public $cartoon;
function __construct($cartoon) {
$this->cartoon = $cartoon;
}
}
$disney = new Disney("The Beauty and The Beast");
$waltDisney = $disney;
$waltDisney->cartoon = "Pinocchio";
echo $disney->cartoon; |
|
0 |
0 |
1 |
0691 |
What happens when you run the following MySQL Query ? |
CREATE TABLE PRIMARY (ID int); |
|
0 |
0 |
1 |
0692 |
What is the output of the following script ? |
function generate() {
for ($i = 1; $i <= 3; $i++) {
yield $i;
}
}
$generator = generate();
if (is_array($generator)) {
echo "Is Array";
} elseif(is_object($generator)) {
echo "Is Object";
} else {
echo "Is none of the above";
} |
|
0 |
0 |
1 |
0693 |
What is the default value for the "max_execution_time" setting when running PHP as a CLI SAPI ? |
|
|
0 |
0 |
1 |
0694 |
What happens when the code below is executed ? |
class foo {
private $variable;
function __construct() {
$this->variable = 1;
}
function __get($name) {
return $this->$name;
}
}
$a = new foo;
echo $a->variable; |
|
0 |
0 |
1 |
0695 |
What happens when the script below is executed ? |
namespace CustomArea;
error_reporting(E_ALL);
ini_set("display_errors", "on");
function var_dump($a) {
return str_replace("Weird", $a, "Weird stuff can happen");
}
$a = "In programming";
echo var_dump($a); |
|
0 |
0 |
1 |
0696 |
When working with unfamiliar code, what is the best way to find out in which file a class is defined ? |
|
|
0 |
0 |
1 |
0697 |
What is the output of the code below ? |
$now = new DateTime();
$now2 = new DateTime();
$ago = new DateInterval('P4Y10M3W');
$ago2 = new DateInterval('P4Y10M2W7D');
$then = $now->sub($ago);
$date1 = $then->format('Y-m-d');
$then2 = $now2->sub($ago2);
$date2 = $then2->format('Y-m-d');
var_dump ($date1 === $date2); |
|
0 |
0 |
1 |
0698 |
Considering the code below |
class AppException extends Exception {
function __toString() {
return "Your code has just thrown an exception: {$this->message}\n";
}
}
class Students {
public $first_name;
public $last_name;
public function __construct($first_name, $last_name) {
if(empty($first_name)) {
throw new AppException('First Name is required', 1);
}
if(empty($last_name)) {
throw new AppException('Last Name is required', 2);
}
}
}
try {
new Students('', '');
} catch (Exception $e) {
echo $e;
} |
Which of these statements are correct ? |
0 |
0 |
1 |
0699 |
What is the output of the code below ? |
$a = array();
$a[0] = 1;
unset($a[0]);
echo ($a != null) ? 'True' : 'False'; |
|
0 |
0 |
1 |
0700 |
What is the output of the code below ? |
namespace animals;
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 'on');
class Cat {
static function Definition() {
return 'Cats are ' . __NAMESPACE__;
}
}
namespace animals\pets;
class Cat {
static function Definition() {
return 'Cats are ' . __NAMESPACE__;
}
}
echo Cat::Definition(); |
|
0 |
0 |
1 |
0701 |
Assuming that the code below is in a file named "test.php" and that PHP has full rights over the file, what happens if the file is executed from the command line without any arguments ? |
exec("rm -f " . dirname(__FILE__) . "/" . $argv[0]); |
|
0 |
0 |
1 |
0702 |
What is the output of the code below ? |
$a = ['one'=>'php', 'two'=>'javascript', 'three'=>'python'];
$b = ['python', 'javascript', 'php'];
echo (array_values(array_reverse($a)) === $b) ? 'true' : 'false'; |
|
0 |
0 |
1 |
0703 |
Which of the statements about traits below are true ? |
|
|
0 |
0 |
1 |
0704 |
When running PHP's built in FastCGI Process Manager (FPM) which of the following statements are true ? |
|
|
0 |
0 |
1 |
0705 |
Considering the following code which of the statements below is true ? |
class entity {
public $name;
}
$human = new entity();
$dog = new entity();
$human->name = 0;
$dog->name = ""; |
|
0 |
0 |
1 |
0706 |
When dealing with cloned objects in PHP, which of the following statements are true ? |
|
|
0 |
0 |
1 |
0707 |
Which of the following statements about object serialization are true ? |
|
|
0 |
0 |
1 |
0708 |
What is the best way to store and verify passwords in PHP ? |
|
|
0 |
0 |
1 |
0709 |
How does Opcode Cache improve performance in PHP 5.5+ ? |
|
|
0 |
0 |
1 |
0710 |
What happens if you execute the code below ? |
class someclass {
public $someprop;
function __construct() {
$this->someprop = 1;
}
}
function somefunc(&$instance) {
unset($instance);
}
$instance = new someclass();
somefunc($instance);
var_dump($instance); |
|
0 |
0 |
1 |
0711 |
Which is a valid way for calling test function? |
function test(?int $n) {
var_dump($n);
} |
|
0 |
0 |
1 |
0712 |
How do you access standard I/O and error streams ? |
|
|
0 |
0 |
1 |
0713 |
What is the result of the code below? |
echo ("0.00") ? "mary" : "angie"; |
|
0 |
0 |
1 |
0714 |
What is the output of the following code: |
function myFunc() {
$in = "nothing";
return func_get_args();
}
$in = "something";
var_dump(myFunc($in)); |
|
0 |
0 |
1 |
0715 |
What are the possible security implications of printing an unfiltered request variable ? |
|
|
0 |
0 |
1 |
0716 |
What is wrong in the following code (assume that $db is an instance of mysqli, mytable exists and has a column called student): |
$sql = "SELECT student FROM mytable WHERE student = '$_POST["student"]'";
if ($result = $db->query($sql)) {
while($row = $result->fetch_object())
echo $row->student;
} |
|
0 |
0 |
1 |
0717 |
Which PHP function(s) can be used to check if a variable is defined and is not NULL ? |
|
|
0 |
0 |
1 |
0718 |
How do you obtain the length of a string in PHP ? |
|
|
0 |
0 |
1 |
0719 |
What is the output of the following snippet ? |
$a = strlen(NULL);
echo $a++; |
|
0 |
0 |
1 |
0720 |
What is the output of the code below ? |
$a = array(0 => "MySQL", 2=>"PHP", 3=>"JAVA", 4 => "JavaScript");
$a = array_values($a);
echo $a[1]; |
|
0 |
0 |
1 |
0721 |
What is the output of the code below ? |
$a = array("PHP", "MySQL", 4, "1");
$sum = array_sum($a);
echo $sum; |
|
0 |
0 |
1 |
0722 |
Considering the table structure below what MySQL query will load a result set containing all students names enrolled in the programming classes ? |
--students table:
| studentid | name |
--------------------
| 1 | Mike |
| 2 | John |
| 3 | Jeff |
| 4 | Anne |
--classes table:
| classid | classname
-------------------------
| 1 | Math
| 2 | Programming
| 3 | Biology
classes_to_students table:
| studentid | classid
-------------------------
| 1 | 1
| 2 | 2
| 3 | 2
| 4 | 3 |
|
0 |
0 |
1 |
0723 |
What happens when the script below is executed ? |
$a = array(1,2,3);
$b = array(7,8,9);
$counta = count($a);
$countb = sizeof($b);
if ($counta===$countb) {
echo "They are equal and have the same type";
} else {
echo "They are not equal or they are not of the same type";
} |
|
0 |
0 |
1 |
0724 |
What is the final value of $i ? |
$numbers = [10, "10", 10.5, "10.5", null, true, false];
$i = 0;
foreach ($numbers as $number) {
if(is_int($number))
$i++;
else
$i--;
}
echo $i; |
|
0 |
0 |
1 |
0725 |
What happens when you run the script below ? |
define("2MYCONSTANT", "avalue");
if(defined("2MYCONSTANT"))
echo "We have a constant: " . 2MYCONSTANT; |
|
0 |
0 |
1 |
0726 |
What happens when you run the script below ? |
$language = 'PHP';
function PHP() {
return 'This is the ' . __FUNCTION__ . ' function';
}
echo $language(); |
|
0 |
0 |
1 |
0727 |
What happens when you run the script below ? |
if(-1)
echo 'TRUE';
else
echo 'FALSE'; |
|
0 |
0 |
1 |
0728 |
Is there a way to make E_NOTICE type errors behave like fatal errors in PHP and therefor stop script execution when such an error occurs ? |
|
|
0 |
0 |
1 |
0729 |
What will happen when you run the code below ? |
function somefunc(DOMDocument $param) {
if($param instanceof DOMDocument)
return 0;
else
return 1;
}
echo somefunc('abcd'); |
|
0 |
0 |
1 |
0730 |
What is the output of the script below ? |
$i = 1;
do {
$i++;
} while ($i===0);
echo $i; |
|
0 |
0 |
1 |
0731 |
Which of the following is the best option to iterate and modify every element of an array ? |
|
|
0 |
0 |
1 |
0732 |
What is the output of the following code? |
$a = 1;
++$a;
$a *= $a;
echo $a--; |
|
0 |
0 |
1 |
0733 |
When PHP is runing on a command line, what super-global will contain the command line arguments specified? |
|
|
0 |
0 |
1 |
0734 |
Function world() is defined in the global namespace 'hello'. Your code is in namespace 'myapp'. What is the correct way to import the namespaceso you can use the world() function? |
|
|
0 |
0 |
1 |
0735 |
What is the output of the following code? |
function fibonacci($x1, $x2) {
return $x1 + $x2;
}
$x1 = 0;
$x2 = 1;
for ($i =0; $i < 10; $i++) {
echo fibonacci($x1, $x2) . ',';
} |
|
0 |
0 |
1 |
0736 |
Which PHP functions may be used to find out whitch PHP extension are available in the system? (Choose 2) |
|
|
0 |
0 |
1 |
0737 |
What is the name of the error level constant that is used to designate PHP code that will not work in future versions? |
|
|
0 |
0 |
1 |
0738 |
Your PHP scripts is repeatedly parseing 50kb of data returned from a remote web service into browser-redable HTML.
Users complain that the script takes a long time to run. Which of the following measures usually leads to the best results? (Choose 2) |
|
|
0 |
0 |
1 |
0739 |
What is goog rule to follow when quoting string data? |
|
|
0 |
0 |
1 |
0740 |
What is will the output of this code be? |
echo strcmp(12345, '12345');
|
|
0 |
0 |
1 |
0741 |
Given a string $str = '12345'; what is the pattern required to extract each digit individually? |
|
|
0 |
0 |
1 |
0742 |
What is the output of the following code? |
$str = 'abcdef';
if (strpos($str, 'a')) {
echo "Found the letter 'a'";
} else {
echo "Could not find the letter 'a'";
} |
|
0 |
0 |
1 |
0743 |
What will this code do? |
$var = 2;
$str = 'aabbccddeeaabbccdd';
echo str_replace('a', 'z', $str, $var); |
|
0 |
0 |
1 |
0744 |
What is the output of the following code? |
$str = printf('%.1f', 7.1);
echo 'Zend PHP Certification ';
echo $str; |
|
0 |
0 |
1 |
0745 |
What is the key difference between HEREDOC and NOWDOC? |
|
|
0 |
0 |
1 |
0746 |
What is the output of the following code? |
$a = array(1, 2, 3);
foreach( $a as $x) {
$x *= 2
}
echo $a[0] * $a[1] * $a[2]; |
|
0 |
0 |
1 |
0747 |
What is the output of the following code? |
$a = ['1' => "A", 1 => "B", 2 => "D"];
echo count($a); |
|
0 |
0 |
1 |
0748 |
Which function can be used to read and parse data from CSV file? |
|
|
0 |
0 |
1 |
0749 |
What is output of the following function call (assuming that foo.txt exist and contains text)? |
$output = file('foo.txt');
|
|
0 |
0 |
1 |
0750 |
What happens if you use fwrite to write data to a readonly file? |
|
|
0 |
0 |
1 |
0751 |
Consider the following snippet of code. What is the name of the function that needs to be inserted in the placeholder? |
$dh = opendir(".");
while ($file = _____($dh)) {
echo $file;
} |
|
0 |
0 |
1 |
0752 |
Which of the following is NOT a default PHP input or output stream? |
|
|
0 |
0 |
1 |
0753 |
Which of the following functions does not accept a stream $context parameter? |
|
|
0 |
0 |
1 |
0754 |
What is the output of the following code? (May be multiple answers) |
function addValues() {
$sum = 0;
for ($i = 0; $i <= func_num_args(); $i++) {
$sum += func_get_arg($i);
}
return $sum;
}
echo addValues(1,2,3); |
|
0 |
0 |
1 |
0755 |
Take a look at the following code |
function myFunction($a) {
$a++;
}
$b = 1;
myFunction($b); |
What code do you need to replace so that $b has the value 2 at the end of the script? (May be multiple answers) |
0 |
0 |
1 |
0756 |
What is the output of the following code? |
$v1 = 1;
$v2 = 2;
$v3 = 3;
function myFunction() {
$GLOBALS['v1'] *= 2;
$v2 *= 2;
global $v3; $v3 *= 2;
}
myFunction();
echo "$v1$v2$v3"; |
|
0 |
0 |
1 |
0757 |
What is the output of the following code? |
function increment($val) {
return ++$val;
}
echo increment(1); |
|
0 |
0 |
1 |
0758 |
What is the relationship between classes and objects? |
|
|
0 |
0 |
1 |
0759 |
What is the output of the following code? |
interface myBaseClass1 {
public function doSomething();
public function specialFunction1();
}
interface myBaseClass2 {
public function doSomething();
public function specialFunction2();
}
class myClassA implements myBaseClass1, myBaseClass2 {
function doSomething() {
echo '...';
}
public function specialFunction1(){
echo '...';
}
public function specialFunction2(){
echo '...';
}
}
$a = new myClassA();
$a->doSomething(); |
|
0 |
0 |
1 |
0760 |
What is the output of the following code? |
abstract class myBaseClass {
abstract protected function doSomething();
function threeDots() {
return '...';
}
}
class myClassA extends myBaseClass {
protected function doSomething() {
echo $this->threeDots();
}
}
$a = new myClassA();
$a->doSomething(); |
|
0 |
0 |
1 |
0761 |
Which of the following statements about static functions is true? |
|
|
0 |
0 |
1 |
0762 |
Which of the following statements about autoloading is true? |
|
|
0 |
0 |
1 |
0763 |
Which of the following cannot be a part of the class definition? |
|
|
0 |
0 |
1 |
0764 |
Reflection functions CANNOT do: |
|
|
0 |
0 |
1 |
0765 |
Of the following statements about typehints, which is NOT true? |
|
|
0 |
0 |
1 |
0766 |
Which is the correct syntax to define a class constant for the class MyClass? |
|
|
0 |
0 |
1 |
0767 |
Which statement about SPLObjectStorage class is NOT true? |
|
|
0 |
0 |
1 |
0768 |
What is the output of the following code? |
class A {
public function __call($f, $arg){
return static::who();
}
public static function who() {
echo __CLASS__;
}
}
class B extends A {
public static function who() {
echo __CLASS__;
}
}
$b = new B();
echo $b->test(); |
|
0 |
0 |
1 |
0769 |
What is the output of the following code? |
class A {
protected $a = '';
function x() {
echo ++$this->a;
}
}
$a = new A();
$b = $a;
$c = new A();
$b->x();
$a->x();
$c->x();
$b = $c;
$b->x();
$a->x(); |
|
0 |
0 |
1 |
0770 |
Which class of HTTP status code is used for error conditions? |
|
|
0 |
0 |
1 |
0771 |
Witch potential security vulnerability is/ vulnerabilities are in the following code? |
<?= htmlspecialchars($_GET['name']); ?>
<a href="<?= $_SERVER['PHP_SELF"] ?>reload</a> |
|
0 |
0 |
1 |
0772 |
What is the base interface all exception inherit? |
|
|
0 |
0 |
1 |
0773 |
What is the result of the following code? |
<?= (function(){ return [$x, $x + 1, $x + 2];})(4)[2]; |
|
0 |
0 |
1 |
0774 |
What is the result of the following code? |
$a = null;
$b = 1;
$c = 'c';
echo $a ?? '!a';
echo $b ?? '!b';
echo $c ?? '!c';
echo $d ?? '!d'; |
|
0 |
0 |
1 |
0775 |
What are the main advantages of replacing many fatal errors with Exceptions in PHP 7? |
|
|
0 |
0 |
1 |
0776 |
What is the result of tht following code? |
echo 1 <=> 2;
echo 'aa' <=> 'zz';
echo [1,2,3] <=> [7,8,9]; |
|
0 |
0 |
1 |
0777 |
What will happen when the following code is executed? |
interface Additionable {
public function add($x, $y);
}
function average ($a, $b) {
$anon = new class implements Additionable {
public function divide($x, $y) {
return $x / $y;
}
public function add($x, $y) {
return $x + $y;
}
};
$sum = $anon->add($a, $b);
$average = $anon->divide($sum, 2);
return $average;
}
echo average(10, 70); |
|
0 |
0 |
1 |
0778 |
Give the following code? |
try {
// ...
} catch (MyEx1 $e) {
logError($e);
} catch (MyEx2 $e) {
logError($e);
} catch (MyEx3 $e) {
logError($e);
} |
Since all "catch" blocks have the same code, how can you avoid duplication here? |
0 |
0 |
1 |
0779 |
What will the following code print on the screen? |
class MyEx1 extends Exception {}
class MyEx2 extends MyEx1 {}
function checkValue(float $a): void {
if ($a < 10) {
throw new MyEx1('too small.');
}
}
try {
checkValue(50);
checkValue(5);
} catch (MyEx2 $e) {
echo $e->getMessage();
} catch (Exception | MyEx1 $e) {
echo get_class($e);
} finally {
echo 'End';
} |
|
0 |
0 |
1 |
0780 |
Can anonymous classes have constructors? |
|
|
0 |
0 |
1 |
0781 |
What does the following code print? |
function getName(): ?string {
return "ElNi\u{{{00F}}}o";
}
echo getName(); |
|
0 |
0 |
1 |
0782 |
What does the following code print? |
function getReduced(int $x) {
$x--;
return $x;
}
function getIncresed(int $x): void {
$x++;
return $x;
}
$x = 0;
$x = getReduced($x);
$x = getIncresed($x);
echo $x; |
|
0 |
0 |
1 |
0783 |
What is the result of the following code? |
class MyCollection {
private $coll = [];
public function add(?int $x): void {
$this->coll[] = $x ?? 0;
}
public function getElements(): iterable {
return $this->coll;
}
}
$collection = new MyCollection();
$collection->add(null);
$collection->add(1);
$collection->add(0);
print_r($collection->getElements()); |
|
0 |
0 |
1 |
0784 |
Give the following code, with a fully autoloaded Symfony framework, what is printed on the screen? |
use Symfony\Component\DependencyInjection\ {
Loader\XmlFileLoader &
Loader\YamlFileLoader as MyFileLoader
}
use Symfony\Component\HttpFoundation\ {
Request &
Response
}
use Symfony\Component\Config\ConfigCache;
echo MyFileLoader::class; |
|
0 |
0 |
1 |
0785 |
What is displayed when the following code is executed? |
class ComparedCollection {
private $es;
private function __construct($es) {
$this->es = $es;
}
public function include(?int $number) {
$this->es[] = $number ?? ($number <=> 0);
}
public function list() {
return $this->es;
}
public static function new() {
return new self([]);
}
}
$c = ComparedCollection::new();
$c->include(-5);
$c->include(0);
$c->include(null);
$c->include(5);
print_r($c->list()); |
|
0 |
0 |
1 |
0786 |
What is displayed when the following code is executed? |
function a(): void {
echo 'Hello';
}
function b(): void {
echo 'World';
return void;
}
a();
b(); |
|
0 |
0 |
1 |
0787 |
What is displayed when the following code is executed? |
abstract class A {
abstract public function f();
}
(new anonymousclass extends A {
public function f() {
echo 'Hello World';
}
})->f(); |
|
0 |
0 |
1 |
0788 |
Which of the statements below are true about PHP 7's new generator-delegation feature? |
|
|
0 |
0 |
1 |
0789 |
Give the following expression: "$$foo['bar']". Which of the statements below are true? |
|
|
0 |
0 |
1 |
0790 |
Give the following function signature: |
function a(): iterable {
//
} |
What actual data types are acceptable for this function to return? |
0 |
0 |
1 |
0791 |
How does the combined comparison operator ("<=>") work when comparing strings? |
|
|
0 |
0 |
1 |
0792 |
What is the result of the following code? |
var_dump(1 < 2 > 1);
|
|
0 |
0 |
1 |
0793 |
What is the result of the following code? |
$x = true and false;
$y = (true and false);
var_dump($x);
var_dump($y); |
|
0 |
0 |
1 |
0794 |
What is the result of the following code? |
var_dump(min(-100, -10, NULL, 10, 100)); |
|
0 |
0 |
1 |
0795 |
What is displayed when the following code is executed? |
$array = array(1, 2, 3, 4, 5);
foreach ($array as $i => $value) {
unset($array[$i]);
}
$array[] = 6;
print_r($array); |
|
0 |
0 |
1 |
0796 |
Which types of form elements can be excluded from the HTTP request? |
|
|
0 |
0 |
1 |
0797 |
Given the following class/interface hierarchy |
Throwable
|__Error
| |__Exception
|
which line entry is at an incorrect position? |
0 |
0 |
1 |
0798 |
What will be the output after the code runs? |
function doSomething($a, $b) {
return $a / $b;
}
try {
doSomething(1);
} catch (Exception $ex) {
echo 1;
} catch (ArgumentCountError $ace) {
echo 2;
} catch (DivisionByZeroError $dbze) {
echo 3;
} |
|
0 |
0 |
1 |
0799 |
What is the output of the following code? |
interface Interface1
{
public function getFoo();
public function setFoo($value);
}
interface Interface2
{
public function getFoo();
public function setBar();
}
class Baz implements Interface1, Interface2
{
public function getFoo() {
return 'foo';
}
public function setFoo($value) {
$this->foo = $value;
}
public function setBar($value) {
$this->bar = $value;
}
}
$baz = new Baz();
$baz->getFoo(); |
|
0 |
0 |
1 |
0800 |
Which of the following statements about exceptions is NOT true? |
|
|
0 |
0 |
1 |
0801 |
What is the ouput of the following code? |
class Magic {
public $a = "A";
protected $b = ["a" => "A", "b" => "B", "c" => "C"];
protected $c = [1, 2, 3];
public function __get($v)
{
echo "$v,";
return $this->b[$v];
}
public function __set($var, $val)
{
echo "$var: $val,";
return $this->$var = $val;
}
}
$m = new Magic();
echo $m->a . "," . $m->b . "," . $m->c . ",";
$m->c = "CC";
echo $m->a . "," . $m->b . "," . $m->c; |
|
0 |
0 |
1 |
0802 |
If a function signature contains three parameters, for which of them may the splat operator be used? |
|
|
0 |
0 |
1 |
0803 |
What is the best way to test if $param is an anonymous function in a method? |
|
|
0 |
0 |
1 |
0804 |
What is the output of the following code? |
function func($x, $x = 2, $x = 3) {
return $x;
}
echo func(3); |
|
0 |
0 |
1 |
0805 |
What is displayed when the following code is executed? |
$a = ['a' => 20, 1 => 36, 40];
array_rand($a);
echo $a[0]; |
|
0 |
0 |
1 |
0806 |
Which of the following types can be used as an array key? (Select three.) |
|
|
0 |
0 |
1 |
0807 |
Consider the following script: |
<?= (int)("77.74" * 100); |
What will be the output of the above PHP script? |
0 |
0 |
1 |