1h 30m 00s
ID: 746
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];
ID: 563
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 "; }
ID: 702
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';
ID: 603
Which of the following is the best way to split a string on the "-=-" pattern?
$string = 'apple-=-banana-=-orange';
str_split($string, strpos($string, "-=-"))
preg_split("-=-", $string);
explode("-=-", $string);
ID: 581
To destroy one variable within a PHP session you should use which method in PHP 5?
ID: 122
Which of the following error constants gives all errors and warnings, except the E_STRICT error level?
E_WARNING
E_ALL
E_ERROR
E_RECOVERABLE_ERROR
ID: 180
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?
ID: 59
You run the following PHP script:
<php echo (int) "Jason 1235";
What will be the output?
ID: 303
Which of the following functions will you use to change the number of bytes to buffer?
ob_buffer_start()
ob_start()
stream_set_write_buffer()
buffer_start()
ID: 11
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); }
ID: 695
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);
ID: 177
Which of the following directives should you delete to secure your applications? Each correct answer represents a complete solution. (Choose all that apply)
ID: 348
What is the difference between including a script with include() and require()?
ID: 763
Which of the following cannot be a part of the class definition?
ID: 708
What is the best way to store and verify passwords in PHP ?
ID: 291
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.
ID: 548
Which of the following extensions are no longer part of PHP 5 and have been moved to PECL?
ID: 398
What is the output of the following PHP script?
$values = array(37, 5, "09"); sort($values, SORT_STRING); foreach ($values as $v) { echo $v; }
ID: 333
define('SOMEVAL', 0); if (strlen(SOMEVAL) > 0) { echo "Hello"; } else { echo "Goodbye"; }
ID: 459
Which of the following statements are true when applied to a Registry pattern? (choose two)
ID: 171
Which of the following functions wraps a string to a given number of characters?
ID: 707
Which of the following statements about object serialization are true ?
ID: 742
$str = 'abcdef'; if (strpos($str, 'a')) { echo "Found the letter 'a'"; } else { echo "Could not find the letter 'a'"; }
ID: 54
Which of the following is NOT a strongly typed language?
ID: 10
Which one of the following four logical operators of PHP is not binary?
ID: 594
What is the best way to ensure that a user-defined function is always passed an object as its single parameter?
ID: 381
How do you create an array called $arr consisting of a single element with the value 15?
$arr = array_shift(15);
$arr = new array(15);
$arr = array(15);
$arr = array_push(15);
ID: 467
$a = 1; function calculate() { global $a; $a += 7; $a = $a * 043; return --$a; } echo $a;
ID: 278
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?
ID: 519
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?
ID: 739
What is goog rule to follow when quoting string data?
ID: 558
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?
ID: 351
$i = ord('a'); do { echo chr($i); } while ($i++ < ord('f') + 1);
Enter the exact script output
ID: 406
$str = 'stingers'; echo strtr($str, 'st', 'bl');
ID: 376
Which function is used to return true if a given value exists in an array (and false if it doesn't)?
in_array()
array_value_exists()
has_value()
array_key_exists()
ID: 280
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>
ID: 477
Which of the following php configuration directives were deprecated in PHP 5.3 (tick as many as apply)?
ID: 537
Which of the following comparisons will evaluate to true?
var_dump( 't' == t, // Notice 1 === "1time", "top" == 0, "top" === 0, 1 == "1time" );
ID: 492
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();
ID: 323
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);
ID: 589
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; }
ID: 360
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;
ID: 451
What would happen when the following code was run?
define('Tree', 'oak'); echo 'This tree is: ' . tree;
ID: 623
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!"; }
ID: 191
Which of the following protocols is normally used by Webservices?
ID: 577
Type-hinting and the instanceof keyword can be used to check what types of things about variables?
ID: 200
Which of the following functions returns an XML string based on SimpleXML element?
xml_error_string()
xml_get_current_byte_index()
xml_get_current_column_number()
asXML()
ID: 530
___ 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.
ID: 650
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?
$_SERVER['HTTP_LOCATION'] != $url
!in_array("Location: $url", headers_list())
!header_exists("Location: $url")
!header_location($url)
ID: 761
Which of the following statements about static functions is true?
ID: 754
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);
ID: 516
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 ?
ID: 283
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:
ID: 159
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.
ID: 697
$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);
ID: 9
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);
ID: 328
Of the following options, which are valid variable names?
$5_name
$25name
$string123
str
ID: 743
What will this code do?
$var = 2; $str = 'aabbccddeeaabbccdd'; echo str_replace('a', 'z', $str, $var);
ID: 429
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);
ID: 653
function byReference(&$variable = 0){ echo ++$variable; } byReference(); byReference();
ID: 265
Which of the following HTML code snippets can be used for the file uploading?
<form enctype="plain" action="index.php" method="post">
<form enctype="application/x-www-form-urlencoded" action="index.php" method="post">
<form enctype="text/plain" action="index.php" method="post">
<form enctype="multipart/form-data" action="index.php" method="post">
ID: 442
What does status code 403 indicate?
ID: 643
When implementing a permissions system for your Web site, what should always be done with regards to the session?
ID: 309
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"; }
ID: 647
Which two internal PHP interfaces provide functionality which allow you to treat an object like an array?
ID: 452
Which of the following are valid constant names? (Choose three)
ID: 420
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"; }
ID: 237
Consider the following PHP code:
<?= strlen(md5(rand(),TRUE));
ID: 331
How do you check if a constant called DEBUG_LEVEL exists in your PHP code?
isset($DEBUG_LEVEL)
defined('DEBUG_LEVEL')
defined($DEBUG_LEVEL)
constant_exists('DEBUG_LEVEL')
ID: 149
Which of the following functions will you use as a countermeasure against a SQL injection attack?
escapeshellcmd()
escapeshellarg()
mysql_fetch_array()
mysqli_escape_string()
ID: 744
$str = printf('%.1f', 7.1); echo 'Zend PHP Certification '; echo $str;
ID: 110
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());
ID: 199
Which of the following was not a built-in terminology before PHP5?
ID: 580
What does the following code print?
echo 2 <=> 1;
ID: 137
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?