Zend Certified PHP Engineer

200-530 | 200-550 | 200-710

Score 0 ( 0 0) 0.00%
Reset

Question ID: bc269a4a6f77824671b84469cba5fd24 [URL]
What is the output of the following code?
echo '1' . (print '2') + 3;





D


Question ID: 6f8363b098f66598e56dc4e6910fccda [URL]
What is the output of the following code?
$a = 3;
switch ($a) {
  case 1: echo 'one'; break;
  case 2: echo 'two'; break;
  default: echo 'four'; break;
  case 3: echo 'three'; break;
}




C


Question ID: ef9aed24755c88a9337023f9e44a755f [URL]
What is "instanceof" an example of?





B


Question ID: 8239a8ae86fc0034d59a671ae8149ec9 [URL]
Which of the following may be used in conjunction with CASE inside a SWITCH statement?




D


Question ID: d92d1d1df01239028797cf1a114bde8b [URL]
What is the output of the following code?
$a = 'a'; $b = 'b';
echo isset($c) ? $a.$b.$c : ($c = 'c').'d';



B


Question ID: ea7cd6dbfa5304a4738cffa23bece6c0 [URL]
What super-global should be used to access information about uploaded files via a POST request?





D


Question ID: 3a30979e6bb2399fbe4d2d702634ec66 [URL]
What is the difference between "print" and "echo"?





B


Question ID: 70aed97b144a3639d6438d7fbb08c0f2 [URL]
What is the output of the following code?
echo "1" + 2 * "0x02";





E

- Letter C is correct if you is running PHP 5 - Letter E is correct if you is running PHP 7 (Best choice)

Question ID: fb5144d3b5d40c2772e225c472da4568 [URL]
What is the result of the following bitwise operation in PHP?
1 ^ 2





B


Question ID: ea07815c4a2834109dd315cd0e0a8186 [URL]
What is the output of the following code?
echo "22" + "0.2", 23 . 1;




B


Question ID: 0b64095a11fe824a9ec4574d0eec7822 [URL]
What is the output of the following code?
$first = "second";
$second = "first";
echo $$$first;




B


Question ID: 8cf2fcb1526a33639d7531d4a860a4b7 [URL]
Your supervisor wants you to disallow PHP scripts to open remote HTTP and FTP resources using PHP's file functions. Which php.ini setting should you change accordingly?

allow_url_fopen, allow_url_fopen=off, allow_url_fopen=Off, allow_url_fopen = off, allow_url_fopen = Off


Question ID: 031c24f72a94810d7248f4aea20054f8 [URL]
Which of the following code snippets DO NOT write the exact content of the file "source.txt" to "target.txt"? (Choose 2)





B,C


Question ID: 780de195ce0c6bad68fddd54f11ba10d [URL]
What is the recommended method of copying data between two opened files?





C


Question ID: c028d8e34c2057e0693598aeb07949e4 [URL]
Which PHP function sets a cookie whose value does not get URL encoded when sending it to the browser?

setrawcookie, setrawcookie()


Question ID: b3dc4271ef898be5e12978d42d16f222 [URL]
Which of the following will set a 10 seconds read timeout for a stream?





D


Question ID: ae7b1017d081d3094473615c24b9d658 [URL]
What function allows resizing of PHP's file write buffer?




C


Question ID: 98acd258682458cca9ee3e40e199ca9a [URL]
What does the __FILE__ constant contain?




B


Question ID: f2f5726ea312fefe8a1313fa55d62ced [URL]
What can prevent PHP from being able to open a file on the hard drive (Choose 2)?




A,B


Question ID: ab3f30b95ef4a4d0b28c8578e4540b9f [URL]
What purpose do namespaces fulfill?




A


Question ID: 1d676cc158ecc9ac250a2e626a5105dc [URL]
When would you use classes and when would you use namespaces?




A


Question ID: 5ddc6f4b16952ba3634e84626430aaa0 [URL]
Which of these elements can be encapsulated by namespaces and made accessible from the outside?



B


Question ID: 4070fa0b3d3bdfd404d6745b24b058ae [URL]
You'd like to use the class MyDBConnection that's defined in the MyGreatFramework\MyGreatDatabaseAbstractionLayer namespace, but you want to minimize *as much as possible* the length of the class name you have to type. What would you do?




C


Question ID: ae6cd75d24886384a9c048a8ab2944b3 [URL]
How should you track errors on your production website?




B


Question ID: d8524612d2ffaed1e24d35c33ad13093 [URL]
What would be the output of the following code?
namespace MyFramework\DB;
class MyClass {
  static function myName() {
    return __METHOD__;
  }
}
print MyClass::myName();




C


Question ID: 3f322421f6724f555217be02fa10bbdc [URL]
Which of the following are valid identifiers? (Choose 3)





B,C,E


Question ID: 2601eb153985b3d866ca05aeca045c39 [URL]
Which of the following methods are available to limit the amount of resources available to PHP through php.ini? (Choose 2)





A,C


Question ID: 467ce859884879a3024378bed1af7283 [URL]
Consider the following two files. When you run test.php, what would the output look like?
// test.php:
include "MyString.php";
print ",";
print strlen("Hello world!");

// MyString.php:
namespace MyFramework\String;
function strlen($str) {
    return \strlen($str)*2; // return double the string length 
}
print strlen("Hello world!")





C


Question ID: 633bd7c5acda8f98124b4b4ccbe0b10f [URL]
Which line of code can be used to replace the INSERT comment in order to output "hello"?
class C {
    public $ello = 'ello';
    public $c;
    public $m;
    function __construct($y) {
        $this->c = static function($f) {
        // INSERT LINE OF CODE HERE
        };
        $this->m = function() {
            return "h";
        };
    }
}
$x = new C("h");
$f = $x->c;
echo $f($x->m);




B


Question ID: 2e1cb61cddeadf5e497c425cbb733305 [URL]
What is the output of the following code?
function z($x) {
    return function ($y) use ($x) {
        return str_repeat($y, $x);
    };
}
$a = z(2);
$b = z(3);
echo $a(3) . $b(2);




B


Question ID: c50e2c7fc8b8eceb7f6f0ba4dfa9636f [URL]
What is the output of the following code?
$f = function () { return "hello"; };
echo gettype($f);




C


Question ID: a6ffc2a332cae7b417866f92fdcde09f [URL]
What is the output of the following code?
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();




D


Question ID: ff3be58bd7a18991ccec3806eb47710b [URL]
Consider the following code. Which keyword should be used in the line marked with "KEYWORD" instead of "self" to make this code work as intended?
abstract class Base {
    protected function __construct()  {}
    public static function create() {
        return new self(); // KEYWORD
    }
    abstract function action();
}
class Item extends Base {
    public function action() { echo __CLASS__; }
}
$item = Item::create();
$item->action(); // outputs "Item"

static


Question ID: 70c5d51ba5633fc39d580e6c135b39b4 [URL]
Which SPL class implements fixed-size storage?

SplFixedArray

Question ID: e4315e655f99284f864c5ecb4f4d3909 [URL]
In order to create an object storage where each object would be stored only once, you may use which of the following? (Choose 2)





Question ID: cab60ae562ad65015527662469ed15a6 [URL]
What is the output of the following code?
class Base {
    protected static function whoami() {
        echo "Base ";
    }
    public static function whoareyou() {
        static::whoami();
    }
}
class A extends Base {
    public static function test() {
        Base::whoareyou();
        self::whoareyou();
        parent::whoareyou();
        A::whoareyou();
        static::whoareyou();
    }
    public static function whoami() {
        echo "A ";
    }
}
class B extends A {
    public static function whoami() {
        echo "B ";
    }
}
B::test(); 




C


Question ID: 3766afac513a2bedb42eee7a0103e28d [URL]
Late static binding is used in PHP to:




B

Question ID: bddbc6631862d11ae6bc7272a1dd5903 [URL]
What is the output of the following code?
class Test {
    public function __call($name, $args) {
        call_user_func_array(array('static', "test$name"), $args);
    }
    public function testS($l) {
        echo "$l,";
   }
}
class Test2 extends Test {
    public function testS($l) {
    echo "$l,$l,";
    }
}
$test = new Test2();
$test->S('A');




Question ID: 60b0ec6bf3fd62761c78894cdf0a8dea [URL]
Which of the following tasks can be achieved by using magic methods? (Choose 3)






A,D,F


Question ID: 52ab64377b19ca77df9c6fc4330e9d42 [URL]
How should class MyObject be defined for the following code to work properly? Assume $array is an array and MyObject is a user-defined class.
$obj = new MyObject();
array_walk($array, $obj);




D

array_walk: http://php.net/manual/en/function.array-walk.php | __invoke: http://php.net/manual/en/language.oop5.magic.php#object.invoke
# __invoke()
# The __invoke() method gets called when the object is called as a function. 
# When you declare it, you say which arguments it should expect. Here's a trivially simple example:
class Butterfly {
    public function __invoke() {
        echo "flutter";
    }
}

# We can instantiate a Butterfly object, and then just use it like a function:
$bob = new Butterfly();
$bob(); // flutter
Source: http://lornajane.net/posts/2012/phps-magic-__invoke-method-and-the-callable-typehint

Question ID: 483af21e45335f5a96717e9f5bdb783e [URL]
Consider the following code. What change must be made to the class for the code to work as written?
class Magic {
    protected $v = array("a" => 1, "b" => 2, "c" => 3);
    public function __get($v) {
        return $this->v[$v];
    }
}
$m = new Magic();
$m->d[] = 4;
echo $m->d[0];





D


Question ID: d3fbf12e5219c0957b1ad3361a12e773 [URL]
SimpleXML provides the ability to iterate over items in an XML document, as well as access items within it as if they were object properties. When creating your own classes to access data, implementing which of the following would NOT achieve this goal?




A


Question ID: b919dc67be617950201c0ab7bd39abab [URL]
Which of the following is used to find all PHP files under a certain directory?




C

RecursiveDirectoryIterator: http://php.net/manual/en/class.recursivedirectoryiterator.php

Question ID: 54729eccfa7ab268234445192adeebba [URL]
Which PHP function is used to validate whether the contents of $_FILES['name']['tmp_name'] have really been uploaded via HTTP?

is_uploaded_file(), is_uploaded_file

Question ID: c0e8f8fe5f8b70225064ebe0fd365b2f [URL]
Which PHP function is used to validate whether the contents of $_FILES['name']['tmp_name'] have really been uploaded via HTTP, and also save the contents into another folder?

move_uploaded_file(), move_uploaded_file

Question ID: b7eca36f4d06421836cf94354dba70cb [URL]
What is the name of the key for the element in $_FILES['name'] that contains the provisional name of the uploaded file?

Question ID: 19bdf1ef21b22b1008ea2dc12f659afc [URL]
What is the name of the key in $_FILES['name'] that contains the number of bytes of the uploaded file?

size


Question ID: 3a555fcebf41308e9d119423e1e26a3c [URL]
What information can be used to reliably determine the type of an uploaded file?



C


Question ID: 8766f5ae58d504fe75254e9ad1e48407 [URL]
Which MIME type is always sent by a client if a JPEG file is uploaded via HTTP?




D


Question ID: 4cbba46b9d96ffb413a2c26bd1b88439 [URL]
Your application uses PHP to accept and process file uploads. It fails to upload a file that is 5 MB in size, although upload_max_filesize is set to "10M". Which of the following configurations could be responsible for this outcome? (Choose 2)





A,D


Question ID: 9224f08a858cc3b36e0d91663c6e72ca [URL]
Consider the following table data and PHP code. What is the outcome?
Table data (table name "users" with primary key "id"):
id name email
------- ----------- -------------------
1 anna alpha@example.com
2 betty beta@example.org
3 clara gamma@example.net
5 sue sigma@example.info
PHP code (assume the PDO connection is correctly established):
$dsn = 'mysql:host=localhost;dbname=exam';
$user = 'username';
$pass = '********';
$pdo = new PDO($dsn, $user, $pass);
$cmd = "SELECT * FROM users WHERE id = :id";
$stmt = $pdo->prepare($cmd);
$id = 3;
$stmt->bindParam('id', $id);
$stmt->execute();
$stmt->bindColumn(3, $result);
$row = $stmt->fetch(PDO::FETCH_BOUND);




D


Question ID: 9e5f3ea1cc9d5ffe9830a905d58a6496 [URL]
Consider the following table data and PHP code. What is the outcome?
Table data (table name "users" with primary key "id"):
id name email
------- ----------- -------------------
1 anna alpha@example.com
2 betty beta@example.org
3 clara gamma@example.net
5 sue sigma@example.info
PHP code (assume the PDO connection is correctly established):
$dsn = 'mysql:host=localhost;dbname=exam';
$user = 'username';
$pass = '********';
$pdo = new PDO($dsn, $user, $pass);
try {
    $cmd = "INSERT INTO users (id, name, email) VALUES (:id, :name, :email)";
    $stmt = $pdo->prepare($cmd);
    $stmt->bindValue('id', 1);
    $stmt->bindValue('name', 'anna');
    $stmt->bindValue('email', 'alpha@example.com');
    $stmt->execute();
    echo "Success!";
} catch (PDOException $e) {
    echo "Failure!";
    throw $e;
}




B


Question ID: 66f7f263ad70e089a8047f898cfb2e14 [URL]
Consider the following table data and PHP code. What is a possible outcome?
Table data (table name "users" with primary key "id"):
id name email
------- ----------- -------------------
1 anna alpha@example.com
2 betty beta@example.org
3 clara gamma@example.net
5 sue sigma@example.info
PHP code (assume the PDO connection is correctly established):
$dsn = 'mysql:host=localhost;dbname=exam';
$user = 'username';
$pass = '********';
$pdo = new PDO($dsn, $user, $pass);
$cmd = "SELECT name, email FROM users LIMIT 1";
$stmt = $pdo->prepare($cmd);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_BOTH);
$row = $result[0];




C


Question ID: 8e6350f845319d0fcd47f0554232f3f9 [URL]
Consider the following table data and PHP code, and assume that the database supports transactions. What is the outcome?
Table data (table name "users" with primary key "id"):
id name email
------- ----------- -------------------
1 anna alpha@example.com
2 betty beta@example.org
3 clara gamma@example.net
5 sue sigma@example.info
PHP code (assume the PDO connection is correctly established):
$dsn = 'mysql:host=localhost;dbname=exam';
$user = 'username';
$pass = '********';
$pdo = new PDO($dsn, $user, $pass);
try {
    $pdo->exec("INSERT INTO users (id, name, email) VALUES (6, 'bill', 'delta@example.com')");
    $pdo->begin();
    $pdo->exec("INSERT INTO users (id, name, email) VALUES (7, 'john', 'epsilon@example.com')");
    throw new Exception();
} catch (Exception $e) {
    $pdo->rollBack();
}




A


Question ID: 91330df95ef3e43dd44417d741aae6d5 [URL]
Given a PHP value, which sample shows how to convert the value to JSON?




A


Question ID: 57e451e6cf66ab5734c3c9302d4828b6 [URL]
Given a JSON-encoded string, which code sample correctly indicates how to decode the string to native PHP values?




C


Question ID: 1511e73351823dce787e3aaefb59c4f5 [URL]
Which of the following PHP values may NOT be encoded to a JavaScript literal using PHP's ext/json capabilities?




B


Question ID: 6a8cc0a0eeabb59033985adbc3a18bf5 [URL]
Which of the following will NOT instantiate a DateTime object with the current timestamp?




D

Question ID: f8589b94f6ad65018e2b89082e1ef3ee [URL]
Given a DateTime object that is set to the first second of the year 2014, which of the following samples will correctly return a date in the format '2014-01-01 00:00:01'?




C

DateTime format: http://php.net/manual/en/datetime.format.php

Question ID: 48dd505e7eac5e1bb93add1d1d0ec426 [URL]
Given the following DateTime objects, what can you use to compare the two dates and indicate that $date2 is the later of the two dates?
$date1 = new DateTime('2014-02-03');
$date2 = new DateTime('2014-03-02');




A


Question ID: 60685eb97fd7e8c5a4f35eeedd3a02c9 [URL]
Given the following DateTime object, which sample will NOT alter the date to the value '2014-02- 15'?
$date = new DateTime('2014-03-15');




D

DateTime diff: http://php.net/manual/en/datetime.diff.php

Question ID: c00ef97145128532c0e87ada2947070e [URL]
Which interfaces could class C implement in order to allow each statement in the following code to work? (Choose 2)
$obj = new C();
foreach ($obj as $x => $y) {
    echo $x, $y;
}




Question ID: 6cd11631cd654e5dbc9b0cc121694b38 [URL]
What is the output of the following code?
class Foo Implements ArrayAccess {
    function offsetExists($k) { return true;}
    function offsetGet($k) {return 'a';}
    function offsetSet($k, $v) {}
    function offsetUnset($k) {}
}
$x = new Foo();
echo array_key_exists('foo', $x)?'true':'false';


B


Question ID: a436a158388f8c1c8ba147c47f3e178b [URL]
What is the output of the following code?
class Bar {
    private $a = 'b';
    public $c = 'd';
}
$x = (array) new Bar();
echo array_key_exists('a', $x) ? 'true' : 'false';
echo '-';
echo array_key_exists('c', $x) ? 'true' : 'false';




B

Question ID: 314d78796fde7d92adb1f6f9dd5aa9ba [URL]
Assuming UTF-8 encoding, what is the value of $count?
$data = '$1Ä2';
$count = strlen($data);




C

strlen: http://php.net/manual/en/function.strlen.php | mb_strlen: http://php.net/manual/en/function.mb-strlen.php
$data = '$1Ä2';
echo strlen($data); // 5
echo mb_strlen($data); // 4

Question ID: bf774ba30f12fc01af88b0e233cb1b4c [URL]
What is the output of this code?
$world = 'world';
echo <<<'TEXT'
    hello $world
    TEXT;



C

HEREDOC: https://secure.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc NOWDOC: https://secure.php.net/manual/en/language.types.string.php#language.types.string.syntax.nowdoc *** Identifier must not be indented *** It is very important to note that the line with the closing identifier must contain no other characters, except a semicolon (;). That means especially that the identifier may not be indented, and there may not be any spaces or tabs before or after the semicolon. It's also important to realize that the first character before the closing identifier must be a newline as defined by the local operating system. This is \n on UNIX systems, including Mac OS X. The closing delimiter must also be followed by a newline.

Question ID: a7258f5796be2c40f491b0797e58ec60 [URL]
Given a php.ini setting of
default_charset = utf-8
what will the following code print in the browser?
header('Content-Type: text/html; charset=iso-8859-1');
echo '&#9986;&#10004;&#10013;';



A


Question ID: 178074a9207dede33360c1ccf3776521 [URL]
What will the following code print out?
$str = '&#10004; one of the following';
echo str_replace('&#10004;', 'Check', $str);



A


Question ID: c7e8f1b9d9585c7cec1f034194477a9c [URL]
What is the pattern modifier for handling UTF-8 encoded preg_* functionality?




Question ID: be36fcd28a5582fddb439caa705cb539 [URL]
What is the output of the following code?
$text = 'This is text';
$text1 = <<<'TEXT'
$text
TEXT;
$text2 = <<<TEXT
$text1
TEXT;
echo "$text2";




B


Question ID: 03f4cdabe33850864e4461b1dca209ab [URL]
Your public web application needs to provide access to binary files for registered users only. How would you achieve this?




C


Question ID: 78137ff005a65b2774fec38bca62443b [URL]
What content-type is required when sending an HTTP POST using JavaScript to ensure that PHP can access the data?




A


Question ID: d83a2f1bfdbd7a73e487e64ecf5c870d [URL]
From your PHP application, how can you send the same header twice, but with different values?




A

Question ID: 17428e5f266adb5b2b743b8757c8a9f3 [URL]
Which class of HTTP status codes is used for server error conditions?




D

Question ID: 9b864950bade8f9a510e5ffe2eb99221 [URL]
Which class of HTTP status codes is used for redirections?




B

Question ID: 59527bbaf946a879f2d9c154754525a6 [URL]
Which of the following can NOT be used to send a cookie from within a PHP application?




B


Question ID: 38c27a11c4579cb2a070a17877dab13d [URL]
Under what condition may HTTP headers be set from PHP if there is content echoed prior to the header function being used?




B

Output Buffering Control: https://secure.php.net/manual/en/book.outcontrol.php

Question ID: 0493196906161373d359508fed03cdb2 [URL]
Before the headers are sent, how can you remove a previously set header?




Question ID: 425e065880e30ede3638f951c1018b80 [URL]
How can you determine whether a PHP script has already sent cookies to the client?




Question ID: bee6e9c4ce5ec62b2a51646cfb15b91e [URL]
An HTML form has two submit buttons. After submitting the form, how can you determine with PHP which button was clicked?




D


Question ID: 429f1dc68ce5e0f1ad918366db102198 [URL]
What is the output of the following code?
function append($str) {
    $str = $str.'append';
}
function prepend(&$str) {
    $str = 'prepend'.$str;
}
$string = 'zce';
append(prepend($string));
echo $string;




C


Question ID: 6dded4e10cef4634e0fcea743f3205f3 [URL]
What is the output of the following code?
function increment ($val) {
    $val = $val + 1;
}
$val = 1;
increment ($val);
echo $val;

1

Note the difference between passing $val by reference vs. passing by value:
function increment ($val) {
    $val = $val + 1;
}
$val = 1;
increment ($val);
echo $val; // output = 1
function increment (&$val) {
    $val = $val + 1;
}
$val = 1;
increment ($val);
echo $val; // output = 2

Question ID: fda523d9133abeb4dd0ca39a63347a63 [URL]
What is the output of the following code?
function increment ($val) {
    ++$val;
}
$val = 1;
increment ($val);
echo $val;

1

Note the difference between passing by reference vs. passing by value:
function increment ($val) {
    ++$val;
}
$val = 1;
increment ($val);
echo $val; // output = 1
function increment (&$val) {
    ++$val;
}
$val = 1;
increment ($val);
echo $val; // output = 2

Question ID: 01c69e012fd055e843fa364a8a3ef8ec [URL]
What is the output of the following code?
function increment ($val) {
    $_GET['m'] = (int) $_GET['m'] + 1;
}
$_GET['m'] = 1;
echo $_GET['m'];

1


Question ID: 4590cc8ecf2cbab9d4b8632be78dcd11 [URL]
How many times will the function counter() be executed in the following code?
function counter($start, &$stop) {
    if ($stop > $start) {
        return;
    }
    counter($start--, ++$stop);
}
$start = 5;
$stop = 2;
counter($start, $stop);




C

Trick: $start-- is always 5:
1x counter(5, 2) //  $start   = 5,   $stop = 2
2x counter(5, 3) //  $start-- = 5, ++$stop = 3
3x counter(5, 4) //  $start-- = 5, ++$stop = 4
4x counter(5, 5) //  $start-- = 5, ++$stop = 5
5x counter(5, 6) //  $start-- = 5, ++$stop = 6
Incrementing/Decrementing Operators: http://php.net/manual/en/language.operators.increment.php

Question ID: 195de8ecb9c7850e59c773e75597d3ee [URL]
How do you allow the caller to submit a variable number of arguments to a function?





B

function func_get_arg: http://php.net/manual/en/function.func-get-args.php

Question ID: d041d2f04b4758134916c073bc143d69 [URL]
What will the $array array contain at the end of this script?
function modifyArray (&$array) {
    foreach ($array as &$value) {
        $value = $value + 1;
    }
    $value = $value + 2;
}
$array = array (1, 2, 3);
modifyArray($array);




B


Question ID: 4e5cb4c2a910a490bfba99378566536b [URL]
What is the output of the following code?
class a {
    public $val;
}
function renderVal (a $a) {
    if ($a) {
        echo $a->val;
    }
}
renderVal (null);




Question ID: 48f0c9b16d470142fa9a2cd334e7ffda [URL]
What is the output of the following code?
function fibonacci (&$x1 = 0, &$x2 = 1) {
    $result = $x1 + $x2;
    $x1 = $x2;
    $x2 = $result;
    return $result;
}
for ($i = 0; $i < 10; $i++) {
    echo fibonacci() . ',';
}




B


Question ID: 131109afc6e057b931d1ba436ccac708 [URL]
What is the output of the following code?
function ratio ($x1 = 10, $x2) {
    if (isset ($x2)) {
        return $x2 / $x1;
    }
}
echo ratio (0);






D


Question ID: 47f99aaed58e8a7253970d9b58222e07 [URL]
Which of the following is NOT a valid function declaration?




D


Question ID: d09db4e7c04da70a85ef64f7960814c5 [URL]
What is the output of the following code?
function increment (&$val) {
    return $val + 1;
}
$a = 1;
echo increment ($a);
echo increment ($a);

22

The variable &$val (by reference) is never modified within the increment function, that is, $val is always 1.

Question ID: 85f792b2b8807a3822e894ff78498c57 [URL]
Which of the following is true about stream contexts? (Choose 2)




A,C

Question ID: 967e2b27446e45d36c66e1c9b1a554c0 [URL]
Consider the following code. What can be said about the call to file_get_contents?
$getdata = "foo=bar";
$opts = array('http' =>
    array(
        'method' => 'POST',
        'header' => 'Content-type: application/x-www-form-urlencoded',
        'content' => $getdata
    )
);
$context = stream_context_create($opts);
$result = file_get_contents('http://example.com/submit.php', false, $context);



B

Question ID: 50bc3ed41bca30f9c482a75a36d5c1d1 [URL]
What function can be used to retrieve an array of current options for a stream context?




C

Question ID: b8e695f631a3df7e960cac00b685dc60 [URL]
When retrieving data from URLs, what are valid ways to make sure all file_get_contents calls send a certain user agent string? (Choose 2)




Question ID: 5b606195213cce0e9dae8b52e45e4b20 [URL]
What will an opcode cache ALWAYS automatically improve?





E


Question ID: c7ebc65002833c0186c15051466c9dfa [URL]
What is cached by an opcode cache?




Question ID: 33323dc9b56d4a55eabba707dc38ef03 [URL]
Which php.ini setting is usually required to use an opcode cache?




B

http://php.net/manual/en/opcache.installation.php OPcache can only be compiled as a shared extension. If you have disabled the building of default extensions with --disable-all , you must compile PHP with the --enable-opcache option for OPcache to be available. Once compiled, you can use the zend_extension configuration directive to load the OPcache extension into PHP. This can be done with zend_extension=/full/path/to/opcache.so on non-Windows platforms, and zend_extension=C:\path\to\php_opcache.dll on Windows.

Question ID: 1673710b40036b6e5c6a0d375cceccd9 [URL]
What is the output of the following code?
var_dump(boolval(-1));


A

Question ID: 24dbb85d954228199db11467a070b2ba [URL]
What is the output of the following code?
var_dump(boolval([]));


B


Question ID: eb9200cee256d467233b046ca8142e0d [URL]
What is the output of the following code?
var_dump(boolval(new StdClass()));


A


Question ID: 21c5394511e4d9426e8397745b0e3ae6 [URL]
Consider the following code:
$result = $value1 ??? $value2;
Which operator needs to be used instead of ??? so that $result equals $value1 if $value1 evaluates to true, and equals $value2 otherwise? Just state the operator as it would be required in the code.

?:


Question ID: 900b5717b8f5ec0b97dc1c6f919ac224 [URL]
Which of the following is NOT true about PHP traits? (Choose 2)






Question ID: 3decd9cff378300b8262706b9521c064 [URL]
Given the following code, what will the output be:
trait MyTrait {
    private $abc = 1;
    public function increment() {
        $this->abc++;
    }
    public function getValue() {
        return $this->abc;
    }
}
class MyClass {
    use MyTrait;
    public function incrementBy2() {
        $this->increment();
        $this->abc++;
    }
}
$c = new MyClass;
$c->incrementBy2();
var_dump($c->getValue());





D


Question ID: cdfa389b15a0510107f2970879d64fee [URL]
Given the following code, how can we use both traits A and B in the same class? (select all that apply)
trait A {
    public function hello() {
        return "hello";
    }
    public function world() {
        return "world";
    }
}
trait B {
    public function hello() {
        return "Hello";
    }
    public function person($name) {
        return ":$name";
    }
}





B


Question ID: ad5707b6860b82e2d797b9d11d5bfb10 [URL]
In the following code, which line should be changed so it outputs the number 2:
class A {
    protected $x = array(); /* A */
    public function getX() { /* B */
        return $this->x; /* C */
    }
}
$a = new A(); /* D */
array_push($a->getX(), "one");
array_push($a->getX(), "two");
echo count($a->getX());





C


Question ID: 50d1955f32ae3fe8bd366ab5a40f956a [URL]
What is the output of the following code?
class A {
    public $a = 1;
    public function __construct($a) { $this->a = $a; }
    public function mul() {
        return function($x) {
            return $this->a*$x;
        };
    }
}
$a = new A(2);
$a->mul = function($x) {
    return $x*$x;
};
$m = $a->mul();
echo $m(3);




B

$a->mul is not the same de $a->mul(). Take a look at $m = $a->mul;
$m = $a->mul();
echo $m(3); // output is 6
$m = $a->mul;
echo $m(3); // output is 9

Question ID: 866b4ee71bdabef6f0f2bc36eb334555 [URL]
What is the output of the following code?
class Number {
private $v = 0;
    public function __construct($v) { $this->v = $v; }
    public function mul() {
        return function ($x) { return $this->v * $x; };
    }
}
$one = new Number(1);
$two = new Number(2);
$double = $two->mul()->bindTo($one);
echo $double(5);

5

Closure::bindTo: http://php.net/manual/en/closure.bindto.php bindTo() Duplicates the closure with a new bound object and class scope.

Question ID: 3cc123f42c05d8b0707bac9649407ae4 [URL]
What is the output of the following code?
class Number {
    private $v;
    private static $sv = 10;
    public function __construct($v) { $this->v = $v; }
    public function mul() {
        return static function ($x) {
            return isset($this) ? $this->v*$x : self::$sv*$x;
        };
    }
}
$one = new Number(1);
$two = new Number(2);
$double = $two->mul();
$x = Closure::bind($double, null, 'Number');
echo $x(5);




C

Closure::bind http://php.net/manual/en/closure.bind.php Closure::bind — Duplicates a closure with a specific bound object and class scope

Question ID: 609707980e64f802e697e9e47996af4b [URL]
Which of the following statements about anonymous functions in PHP are NOT true? (Choose 2)





B,C

Anonymous functions: http://php.net/manual/en/functions.anonymous.php

Question ID: 942a22d2ee9670d7badfdd623f435992 [URL]
What will be the result of the following operation?
$a = array_merge([1,2,3] + [4=>1,5,6]);
echo $a[2];





B


Question ID: fb15a2760a55a4507ee4073bac897077 [URL]
Which of the following functions will allow identifying unique values inside an array?





C

array_count_values: http://php.net/manual/en/function.array-count-values.php array_count_values() returns an array using the values of array as keys and their frequency in array as values.
$array = array(1, "hello", 1, "world", "hello");
print_r(array_count_values($array));

/* output
Array
(
    [1] => 2
    [hello] => 2
    [world] => 1
)
*/

Question ID: 5f737bd38b8df74cb035bb1f7145439a [URL]
When using password_hash() with the PASSWORD_DEFAULT algorithm constant, which of the following is true? (Choose 2)




A,C

Question ID: 878783ac999ddcecd731498f839b48c8 [URL]
Which of the following are NOT acceptable ways to create a secure password hash in PHP? (Choose 2)





A,E


Question ID: a1a5846c5a11223afe5a31959a2f94f3 [URL]
What is the preferred method for preventing SQL injection?





Question ID: aec3d63149706a14ae006b855c60c05c [URL]
Is the following code vulnerable to SQL Injection ($mysqli is an instance of the MySQLi class)?
$age = $mysqli->real_escape_string($_GET['age']);
$name = $mysqli->real_escape_string($_GET['name']);
$query = "SELECT * FROM `table` WHERE name LIKE '$name' AND age = $age";
$results = $mysqli->query($query);





D

mysqli::real_escape_string: http://php.net/manual/en/mysqli.real-escape-string.php $age variable is improperly escaped, like this example:
// SQL injections
$query = "SELECT id, title, body FROM posts WHERE id = " . mysql_real_escape_string($_GET['id']);

// This can still be injected:
1 OR 1=1

// Resulting in:
SELECT id, title, body FROM posts WHERE id = 1 OR 1=1

// All results are returned. Not convinced this is bad? Ok...
1 OR 1=1 UNION SELECT id, username, password FROM users

// Whoops! Why is this injectable? The developer just forgot to quote the numeric ID.
Source: http://stackoverflow.com/questions/16173027/mysql-real-escape-string-not-escaping-all-types-of

Question ID: 07ab1f85db7bd11de127fe2de99376bd [URL]
Which of the following does NOT help to protect against session hijacking and fixation attacks?





Question ID: 2291690ff2529a40723eda31dd0847e9 [URL]
Please provide the value of the $code variable in the following statement to set an HTTP status code that signifies that the requested resource was not found.
http_response_code($code);

404, 404 Not Found

Question ID: 2f31a8111418387ec3e9feca4eeb0ecc [URL]
Which of the following PHP functions can be used to set the HTTP response code? (Choose 2)





B,D


Question ID: 6660b47be5af162bc85cc3eddb925987 [URL]
What is the name of the header used to require HTTP authentication?





B


Question ID: 5a28c9fc891c05ebc3932d3a5c07b006 [URL]
What types of HTTP authentication are supported by PHP? (Choose 2)





A,D

Both "Basic" and "Digest" (since PHP 5.1.0) authentication methods are supported. HTTP authentication with PHP: http://php.net/manual/en/features.http-auth.php

Question ID: e756237749433a446b1d25da97c7b294 [URL]
Which of the following items in the $_SERVER superglobal are important for authenticating the client when using HTTP Basic authentication? (Choose 2)





D,E

HTTP authentication with PHP: http://php.net/manual/en/features.http-auth.php

Question ID: 1a4cd8c966f5c711a67f239f6edc3ed5 [URL]
When tracking upload progress with sessions, the values of 2 INI settings are needed to determine the key in $_SESSION of the upload progress data. What are the INI settings? (Choose 2)





C,E

Session Upload Progress: http://php.net/manual/en/session.upload-progress.php#session.upload-progress The upload progress will be available in the $_SESSION superglobal when an upload is in progress, and when POSTing a variable of the same name as the session.upload_progress.name INI setting is set to. When PHP detects such POST requests, it will populate an array in the $_SESSION, where the index is a concatenated value of the session.upload_progress.prefix and session.upload_progress.name INI options.

Question ID: b26a2edc2f4573594a95719d9c6c7bdc [URL]
What is the name of the function that allows you register a set of functions that implement user- defined session handling?




D

Question ID: 084a4d8ac1ce57df306755d1ffdf17ab [URL]
Which of these databases is NOT supported by a PDO driver?




D

Question ID: b894e443e5bb048278c857cecfcb3e38 [URL]
Which of these statements about PDO is NOT true?




B

PDO::prepare: http://php.net/manual/pt_BR/pdo.prepare.php The SQL statement can contain zero or more named (:name) or question mark (?) parameter markers for which real values will be substituted when the statement is executed. You cannot use both named and question mark parameter markers within the same SQL statement.

Question ID: 5235e00e93e33897291adeb5e7ee80ec [URL]
What is the output of the following code?
class test {
    public $value = 0;
    function test() {
        $this->value = 1;
    }
    function __construct() {
        $this->value = 2;
    }
}
$object = new test();
echo $object->value;





A


Question ID: a2ecbb6c5f8de533824dcf592be80788 [URL]
Which methods can be used to overload object properties? (Choose 2)





B,E

Question ID: 213d1afa5f7295b6f53c16e4ac33d02b [URL]
What is the result of the following code?
class T {
    const A = 42 + 1;
}
echo T::A;



B

Constants Syntax: http://php.net/manual/en/language.constants.syntax.php When using the const keyword, only scalar data (boolean, integer, float and string) can be contained in constants prior to PHP 5.6. From PHP 5.6 onwards, it is possible to define a constant as a scalar expression, and it is also possible to define an array constant. However, below PHP 5.6 C is correct.

Question ID: f5ce47b4837f6c6703e0004436248910 [URL]
Which of the following statements is NOT true?




C

Constants: http://php.net/manual/en/language.constants.php As the name suggests, that value cannot change during the execution of the script. So It does not make sense to create a constant without initialization, since later it will not be possible to change it, like this:
const MY_CONSTANT;
echo MY_CONSTANT; // Output: syntax error, unexpected ';', expecting '=' 

Question ID: d0e83a242539731d148bf727a7528599 [URL]
What is the result of the following code?
define('PI', 3.14);
class T {
    const PI = PI;
}
class Math {
    const PI = T::PI;
}
echo Math::PI;




B


Question ID: 08824960345d82f4ec56dfea31143819 [URL]
Given the following code, what is correct?
function f(stdClass &$x = NULL) { $x = 42; }
$z = new stdClass;
f($z);
var_dump($z);





E


Question ID: 16e4f52ed06f9611b0299b1f195dc220 [URL]
Which of the following statements is NOT correct?



A

Function arguments (type hints): http://php.net/manual/en/functions.arguments.php

Question ID: 4b577a6cb44b4d52590582d19267ca2d [URL]
Which of the following statements is correct?




B


Question ID: 3231453fd805ce37ac93ebbac0390c8b [URL]
Which of the following statements about exceptions is correct? (Choose 2)




A,B

Question ID: cfaa4d2aaf4e0a5d953452fc60c14078 [URL]
What is the output of the following code?
try {
    class MyException extends Exception {};
    try {
        throw new MyException;
    }
    catch (Exception $e) {
        echo "1:";
        throw $e;
    }
    catch (MyException $e) {
        echo "2:";
        throw $e;
    }
}
catch (Exception $e) {
    echo get_class($e);
}







E


Question ID: f092aa4009f6c28b8fe5681fcd435c8a [URL]
Which of the following is NOT possible using reflection?




C

Reflection: http://php.net/manual/en/book.reflection.php PHP 5 comes with a complete reflection API that adds the ability to reverse-engineer classes, interfaces, functions, methods and extensions. Additionally, the reflection API offers ways to retrieve doc comments for functions, classes and methods.

Question ID: fc98e10559097193d310c3790d9e70a0 [URL]
What is the name of the method that can be used to provide read access to virtual properties in a class?





B


Question ID: 3629c941009f1646266700918348d916 [URL]
Which of the following statements about Reflection is correct?




D


Question ID: 5cca82f825e0a430c841d811bd24819b [URL]
What is the name of the PHP function used to automatically load non-yet defined classes?





B


Question ID: 4ebf4cdba58eafad3122decec2eaefc9 [URL]
When a class is defined as final it:




A


Question ID: bc4bfed8e3118282b9cad0bf14d28193 [URL]
Type hinting in PHP allows the identification of the following variable types: (Choose 2)





E

The answer is C,D to PHP < 7 and E if PHP >= 7 The following types for parameters can now be enforced: - strings (string), - integers (int), - floating-point numbers (float), and - booleans (bool). They augment the other types introduced in PHP 5: - class names, - interfaces, - array and - callable Source: https://secure.php.net/manual/en/migration70.new-features.php

Question ID: 69fb64a72b7026470154e2c48c159514 [URL]
In the following code, which classes can be instantiated?
abstract class Graphics {
    abstract function draw($im, $col);
}
abstract class Point1 extends Graphics {
    public $x, $y;
    function __construct($x, $y) {
        $this->x = $x;
        $this->y = $y;
    }
    function draw($im, $col) {
        ImageSetPixel($im, $this->x, $this->y, $col);
    }
}
class Point2 extends Point1 { }
abstract class Point3 extends Point2 { }





C

Class Abstraction: http://php.net/manual/en/language.oop5.abstract.php PHP 5 introduces abstract classes and methods. Classes defined as abstract may not be instantiated, and any class that contains at least one abstract method must also be abstract. Methods defined as abstract simply declare the method's signature - they cannot define the implementation.

Question ID: fc807df7b502593a673025d9582d885d [URL]
Which of the following code snippets is correct? (Choose 2)




B,C

Object Interfaces:http://php.net/interface - All methods declared in an interface must be public; this is the nature of an interface (Reason why A is not correct). - Interfaces can be extended like classes using the extends operator (Reason why D is not correct).

Question ID: ed93573abcfd697fcc175511ddcb6819 [URL]
Which of the following statements about PHP is false? (Choose 2)





A,E

Final Keyword: http://php.net/manual/en/language.oop5.final.php PHP 5 introduces the final keyword, which prevents child classes from overriding a method by prefixing the definition with final. If the class itself is being defined final then it cannot be extended.

Question ID: 97cc83efdaba71b70de7f822ef194c57 [URL]
Which of the following is correct? (Choose 2)






D,E


Question ID: f0509dd0acd9d2c7bd168fb7ab8b04c6 [URL]
Which of the following functions are used to escape data within the context of HTML? (Choose 2)





A,E


Question ID: babaede3446d5312ee0c167a13449aa8 [URL]
In a shared hosting environment, session data can be read by PHP scripts written by any user. How can you prevent this? (Choose 2)




A,B


Question ID: 765a0f85a5428b9ebb1ffeafc0e6b4f8 [URL]
Which of the following filtering techniques prevents all cross-site scripting (XSS) vulnerabilities?




D


Question ID: 0f0e64b958c1184319781cd933b6fcdf [URL]
You work for a shared hosting provider, and your supervisor asks you to disable user scripts to dynamically load PHP extensions using the dl() function. How can you do this? (Choose 2)




Question ID: 2f2a90f7a6d7abbf22a757e6cdd9f69d [URL]
When a browser requests an image identified by an img tag, it never sends a Cookie header.


B


Question ID: b6e7a6d53800a501e603a8e26f91ad43 [URL]
Which of the following techniques ensures that a value submitted in a form can only be yes or no ?




D


Question ID: 885a501a1b42d1db9732290dcded978a [URL]
Which function can NOT help prevent cross-site scripting? (Choose 2)





A,E


Question ID: d1925c398adedba6c474616a2020522a [URL]
Which constant must be passed as the second argument to htmlentities() to convert single quotes (') to HTML entities?





C

htmlentities: https://secure.php.net/manual/en/function.htmlentities.php ENT_QUOTES will convert both double and single quotes.

Question ID: 1ae4eaf17fa7c9a4964e6b8341fabecf [URL]
One common security risk is exposing error messages directly in the browser. Which PHP configuration directive can be disabled to prevent this?





Question ID: 37717ce99d2f90bdc4e32613bd9150d0 [URL]
Which of the following superglobals does not necessarily contain data from the client?




B


Question ID: 5b77ebe6f8b539bcc6cf5c46e8a8df11 [URL]
Which of the following statements is true?




D


Question ID: 6b13b68449c844e744827194b628c93f [URL]
Transactions are used to...





B


Question ID: 28c8b159f201d7a6f803124145beca3b [URL]
When a query that is supposed to affect rows is executed as part of a transaction, and reports no affected rows, it could mean that: (Choose 2)




A,B


Question ID: b6b13cb53be8442ae4b56cfa44d33529 [URL]
Transactions should be used to: (Choose 2)




A,C


Question ID: f4a20959db5d25e8a0bfadc680901801 [URL]
An unbuffered database query will: (Choose 2)




A,D

Buffered and Unbuffered queries: http://php.net/manual/pt_BR/mysqlinfo.concepts.buffering.php

Question ID: 622cdcc87af518f9e53e8be7543d867c [URL]
Which technique should be used to speed up joins without changing their results?




A


Question ID: 0ad65a244ebd87ac81f9e838fc814334 [URL]
Consider the following XML code:
<?xml version="1.0" encoding="utf-8"?>
<books>
<book id="1">PHP 5.5 in 42 Hours</book>
<book id="2">Learning PHP 5.5 The Hard Way</book>
</books>
Which of the following SimpleXML calls prints the name of the second book?
(Let $xml = simplexml_load_file("books.xml"); .)   (Choose 2)





C,E


Question ID: 8e7f2e3d939b459a3e7d09862130aa01 [URL]
What method can be used to find the tag <any> via the DOM extension?





B

DOMDocument::getElementsByTagName: http://php.net/manual/en/domdocument.getelementsbytagname.php DOMDocument::getElementsByTagName — Searches for all elements with given local tag name.

Question ID: 9126d8015869cf3e32c0daad22834f8b [URL]
What DOMElement method should be used to check for availability of a non-namespaced attribute?




C

DOMElement::hasAttribute: http://php.net/manual/en/domelement.hasattribute.php DOMElement::hasAttribute — Checks to see if attribute exists.

Question ID: 74232745bf8091108e7694f201fd113d [URL]
Which of the following is an invalid DOM save method?





B

http://php.net/manual/en/domdocument.save.php DOMDocument::save — Dumps the internal XML tree back into a file. DOMDocument::saveHTML — Dumps the internal document into a string using HTML formatting. DOMDocument::saveHTMLFile — Dumps the internal document into a file using HTML formatting. DOMDocument::saveXML — Dumps the internal XML tree back into a string.

Question ID: ba608875bc8b8480b9ecdebe7aac7a7d [URL]
Which of the following rules must every correct XML document adhere to? (Choose 2)




A,B


Question ID: 59aec3a79a5b9f7ed067b5c3f3b6f4aa [URL]
Which one of the following XML declarations is NOT valid?




D


Question ID: 771729ba0dbd41e4a1a1aab7ea5221e5 [URL]
Which of the following parts must a XML document have in order to be well-formed?




B


Question ID: c37751173bd8993c057054bcf518548b [URL]
Which of the following can be registered as entry points with a SoapServer instance (choose 2):




A,C


Question ID: 6a5cdefdc079730394232b9e48de6536 [URL]
Which of the following statements about SOAP is NOT true?




C


Question ID: b9d45a9e0327e1354306538c4345ef16 [URL]
What SimpleXML function is used to parse a file?






A

Question ID: 852bb5adcdd524f008c8e0be5057745b [URL]
The XML document below has been parsed into $xml via SimpleXML. How can the value of <foo> tag accessed?
<?xml version='1.0'?>
<document>
    <bar>
        <foo>Value</foo>
    </bar>
</document>





B


Question ID: c7cc9d143fd5438ebfbfda63456bdc42 [URL]
What parsing methodology is utilized by the SimpleXML extension?





B


Question ID: 5bd4064a7135043ca54e1bac3c07a17e [URL]
How can the id attribute of the 2nd baz element from the XML string below be retrieved from the SimpleXML object found inside $xml?
<?xml version='1.0'?>
<foo>
    <bar>
        <baz id="1">One</baz>
        <baz id="2">Two</baz>
    </bar>
</foo>





E


Question ID: b6f7a833f66bbc3ca48579ef2633f6cd [URL]
How can a SimpleXML object be converted to a DOM object?





A

Question ID: 0e4b99213fafe6df3e682fe644132e8d [URL]
What is the method used to execute XPath queries in the SimpleXML extension?





B

SimpleXMLElement::xpath: http://php.net/manual/en/simplexmlelement.xpath.php

Question ID: 1eaac2b45bd685181cdf4906c1b6bbf9 [URL]
Which of the following statements are FALSE?





E


Question ID: e5e320c39d696174e5f307b93e39bf64 [URL]
What DOM method is used to load HTML files?




D

DOMDocument::loadHTMLFile: http://php.net/manual/en/domdocument.loadhtmlfile.php

Question ID: 72df7b765cbd8c468e1ed6b84afe9926 [URL]
What is the output of the following code?
for ($i = 0; $i < 1.02; $i += 0.17) {
    $a[$i] = $i;
}
echo count($a);





B


Question ID: 053d699261b7568939ec1b6f8fe86942 [URL]
After performing the following operations:
$a = array('a', 'b', 'c');
$a = array_keys(array_flip($a));
What will be the value of $a?




C

array_flip: http://php.net/manual/en/function.array-flip.php array_flip — Exchanges all keys with their associated values in an array. array_keys: http://php.net/manual/en/function.array-keys.php array_keys — Return all the keys or a subset of the keys of an array.

Question ID: 95b2043e2df332f0057f2259c88b0e0a [URL]
PHP's array functions such as array_values() can be used on an object if the object...




D

The ArrayObject class: http://php.net/manual/en/class.arrayobject.php The ArrayAccess interface: http://php.net/manual/en/class.arrayaccess.php

Question ID: 357e841ddb5dcbdf7d1fdcacc9c49d2c [URL]
Which is the most efficient way to determine if a key is present in an array, assuming the array has no NULL values?




B

array_key_exists: http://php.net/manual/en/function.array-key-exists.php array_key_exists — Checks if the given key or index exists in the array. in_array: http://php.net/manual/en/function.in-array.php in_array — Checks if a value exists in an array. Example #1 array_key_exists() vs isset()
// isset() does not return TRUE for array keys that correspond to a NULL value, while array_key_exists() does.
$search_array = array('first' => null, 'second' => 4);

// returns false
isset($search_array['first']);

// returns true
array_key_exists('first', $search_array);

Question ID: c076696c36797a5c49a508aa48afa495 [URL]
An object can be counted with count() and sizeof() if it...




D


Question ID: 1c20bd53249defe4980f92622cb264a1 [URL]
Which value will be assigned to the key 0 in this example?
$foo = array(true, '0' => false, false => true);

true


Question ID: 4ef97f8d2d9c29cf0a713b52cc503eb2 [URL]
What will be the result of the following operation?
array_combine(array("A","B","C"), array(1,2,3));





C

array_combine: http://php.net/manual/en/function.array-combine.php array_combine — Creates an array by using one array for keys and another for its values

Question ID: ee1cf8f60136adca9cba387b1d320fd9 [URL]
Which of the following expressions will evaluate to a random value from an array below?
$array = array("Sue","Mary","John","Anna");





D

array_rand: http://php.net/manual/en/function.array-rand.php array_rand — Pick one or more random entries out of an array. When picking only one entry, array_rand() returns the key for a random entry. Otherwise, an array of keys for the random entries is returned. This is done so that random keys can be picked from the array as well as random values. Trying to pick more elements than there are in the array will result in an E_WARNING level error, and NULL will be returned.

Question ID: 76dcaaf5e4d6f245dbed0a8791a195c6 [URL]
What function can reverse the order of values in an array so that keys are preserved?





B

array_reverse: http://php.net/manual/en/function.array-reverse.php array_reverse — Return an array with elements in reverse order. If 2nd parameter set to TRUE, numeric keys are preserved. Non-numeric keys are not affected by this setting and will always be preserved.

Question ID: 44b68da711dd78df9f82672bd7ef45d4 [URL]
What will be the output value of the following code?
$array = array(1,2,3);
while (list(,$v) = each($array));
var_dump(current($array));





A

list: http://php.net/manual/en/function.list.php list — Assign variables as if they were an array each: http://php.net/manual/en/function.each.php each — Return the current key and value pair from an array and advance the array cursor. current: http://php.net/manual/en/function.current.php current — Return the current element in an array. The current() function simply returns the value of the array element that's currently being pointed to by the internal pointer. It does not move the pointer in any way. If the internal pointer points beyond the end of the elements list or the array is empty, current() returns FALSE.

Question ID: cdf32f3f63d8b1b64a89538f8238e933 [URL]
What will be the output of the following code?
$a = array(0, 1, 2 => array(3, 4));
$a[3] = array(4, 5);
echo count($a, 1);




C

count: http://php.net/manual/en/function.count.php count — Count all elements in an array, or something in an object. If the 2nd parameter (optional) is set to COUNT_RECURSIVE (or 1), count() will recursively count the array. This is particularly useful for counting all the elements of a multidimensional array.

Question ID: df1457a6da118d89c1ef2c64d26012e3 [URL]
Given the following array:
$a = array(28, 15, 77, 43);
Which function will remove the value 28 from $a?




A

array_shift: http://php.net/manual/en/function.array-shift.php array_shift — Shift an element off the beginning of array.

Question ID: 3ce419f3c33a1f533f4190c21d562385 [URL]
The constructs for(), foreach(), and each() can all be used to iterate an object if the object...




C

The Iterator interface: http://php.net/manual/en/class.iterator.php The ArrayAccess interface: http://php.net/manual/en/class.arrayaccess.php

Question ID: 5efa0629028333ab371d1bd0113992c1 [URL]
Which parts of the text are matched in the following regular expression?
$text = <<<EOT
The big bang bonged under the bung.
EOT;
preg_match_all('@b.n?g@', $text, $matches);




C


Question ID: 5e9899e4f927ef36ccf88cfcab1fce0e [URL]
What will the following code piece print?
echo strtr('Apples and bananas', 'ae', 'ea')




A

strtr: http://php.net/manual/en/function.strtr.php strtr — Translate characters or replace substrings. Once a substring has been replaced, its new value will not be searched again.
Apples end benenes // 1st: change a -> e, note Apples has not been changed
Applas end benenes // 2nd: change e -> a, only where it has not been changed yet, that is, Apples change to Applas

Question ID: 8fb9995dccfaafaf1eb38df40c98449b [URL]
You want to parse a URL into its single parts. Which function do you choose?




A

parse_url: http://php.net/manual/en/function.parse-url.php parse_url — Parse a URL and return its components.

Question ID: bc9e16ef70d2117f3a54ec3f5d805e1a [URL]
Which elements does the array returned by the function pathinfo() contain?




C

pathinfo: http://php.net/manual/en/function.pathinfo.php pathinfo — Returns information about a file path. pathinfo() returns information about path: either an associative array or a string, depending on options. If the options parameter is not passed, an associative array containing the following elements is returned: dirname, basename, extension (if any), and filename.

Question ID: 8602f171a4bcf53066136e87ffaf2859 [URL]
What will the following function call print?
printf('%010.6f', 22);




C

Question ID: 858f759aa7501a62f4694b9c13172e18 [URL]
What is the output of the following code?
echo 0x33, ' monkeys sit on ', 011, ' trees.';




B


Question ID: 95229e10df231ce4c8996bc803fe6c7c [URL]
You want to access the 3rd character of a string, contained in the variable $test. Which of the following possibilites work? (Choose 2)





B,D


Question ID: 920d263ea8ced7e64fd425f933a633e7 [URL]
Which sentence describes the following regular expression match?
preg_match('/^\d+(?:\.[0-9]+)?$/', $test);





B


Question ID: 57cc06683aa2ffb2a641b7cda2d572ba [URL]
You need to escape special characters to use user input inside a regular expression. Which functions would you use? (Choose 2)





C,E

preg_quote: https://secure.php.net/manual/en/function.preg-quote.php preg_quote — Quote regular expression characters. quotemeta: https://secure.php.net/manual/en/function.quotemeta.php quotemeta — Quote meta characters.

Question ID: dbf9d3f864206817547438e4b32d5d5b [URL]
How many elements does the $matches array contain after the following function call is performed?
preg_match('/^(\d{1,2}([a-z]+))(?:\s*)\S+ (?=201[0-9])/', '21st March 2014', $matches);




C


Question ID: dfc52ac06287ada8d7e8ba6d29eaa5b6 [URL]
How many elements does the array $matches from the following code contain?
$str = "The cat sat on the roof of their house.";
$matches = preg_split("/(the)/i", $str, -1, PREG_SPLIT_DELIM_CAPTURE);





D

preg_split: http://php.net/manual/en/function.preg-split.php preg_split — Split string by a regular expression. PREG_SPLIT_DELIM_CAPTURE If this flag is set, parenthesized expression in the delimiter pattern will be captured and returned as well.

Question ID: c86902be6ec448c90072f24785bdd529 [URL]
Given the default PHP configuration, how can all of the parameters provided via GET be accessed in a form of a string?





Question ID: aecb8f45a683a40cd10e0585a0cc4626 [URL]
What is the length of a string returned by:
md5(rand(), TRUE);





D

md5: http://php.net/manual/en/function.md5.php md5 returns the hash as a 32-character hexadecimal number, but if the optional 2nd parameter is set to TRUE, then the md5 digest is instead returned in raw binary format with a length of 16.

Question ID: 2e77d7e551876cd6a8e819af90943667 [URL]
What is the return value of the following code?
strpos("me myself and I", "m", 2)





B

strpos: http://php.net/manual/en/function.strpos.php strpos — Find the position of the first occurrence of a substring in a string. If 3rd parameter is specified, search will start this number of characters counted from the beginning of the string. If is negative, the search will start this number of characters counted from the end of the string.

Question ID: ec300f980bb80fd7cc903b733fba70cc [URL]
What is the return value of the following code: substr_compare("foobar", "bar", 3);





D

substr_compare: http://php.net/manual/en/function.substr-compare.php substr_compare — Binary safe comparison of two strings from an offset, up to length characters. substr_compare returns < 0 if comparison is less, > 0 if it is greater, and 0 if it is equal.

Question ID: 8ec01c164e1b6ec0cd3d1d6c7fc207bf [URL]
You want to allow your users to submit HTML code in a form, which will then be displayed as real code and not affect your page layout. Which function do you apply to the text, when displaying it? (Choose 2)





B,D


Question ID: 28cee6a51e62f9539826edd0fa5619db [URL]
How many elements does the array $pieces contain after the following piece of code has been executed?
$pieces = explode("/", "///");




C


Question ID: 8bf713737b520115bb98e7ed6d3fb643 [URL]
Which string will be returned by the following function call?
$test = '/etc/conf.d/wireless';
substr($test, strrpos($test, '/')); // note that strrpos() is being called, and not strpos()





B

strrpos: http://php.net/manual/en/function.strrpos.php strrpos — Find the position of the last occurrence of a substring in a string (reverved).

Question ID: 4bd215c941c9cc0c7cad553109dc9a03 [URL]
An HTML form contains this form element:
<input type="file" name="myFile" />
When this form is submitted, the following PHP code gets executed:
move_uploaded_file(
$_FILES['myFile']['tmp_name'],
'uploads/' . $_FILES['myFile']['name']
);
Which of the following actions must be taken before this code may go into production? (Choose 2)





B,D


Question ID: 07ba143df698eb0b4e3ec5a52c21e90b [URL]
Which PHP function retrieves a list of HTTP headers that have been sent as part of the HTTP response or are ready to be sent?





C

headers_list: http://php.net/manual/en/function.headers-list.php headers_list — Returns a list of response headers sent (or ready to send).

Question ID: 0501897de380d238919c5ea0f9b9df80 [URL]
Which options do you have in PHP to set the expiry date of a session?




D


Question ID: b0f5674729e1d679d4997a097f3beae0 [URL]
The following form is loaded in a browser and submitted, with the checkbox activated:
<form method="post">
    <input type="checkbox" name="accept" />
</form>
In the server-side PHP code to deal with the form data, what is the value of $_POST['accept'] ?




D


Question ID: 1e464e009b5b44d822f19e354cbf0220 [URL]
When uploading a file to a PHP script using the HTTP PUT method, where would the file data be found?




B

Question ID: 68431b0312d169dca36aa1d8ea3d1a50 [URL]
Please provide the name of the super-global variable where all the information about cookies is available.

$_COOKIE, $_COOKIE[\], _COOKIE, _COOKIE[\]


Question ID: ea9672984b60c5270518304f1021505e [URL]
The following form is loaded in a recent browser and submitted, with the second select option selected:
<form method="post">
    <select name="list">
        <option>one</option>
        <option>two</option>
        <option>three</option>
    </select>
</form>
In the server-side PHP code to deal with the form data, what is the value of $_POST['list'] ?




C


Question ID: 2c3359adb2bb0d44c8b0b80df6b0ac67 [URL]
Which of the following is NOT a requirement for file uploads to work?




C


Question ID: 2de46462a75ec1e970259fe233d029f8 [URL]
An HTML form contains this form element:
<input type="image" name="myImage" src="image.png" />
The user clicks on the image to submit the form. How can you now access the relative coordinates of the mouse click?




D


Question ID: f14f7435011f501bbe8db78dda011e05 [URL]
Which PHP function sets a cookie and URL encodes its value when sending it to the browser?

setcookie, setcookie()


Question ID: 4a0898a1eb2f88f8b2838502c1281272 [URL]
What elements will the following script output?
<?php
$array = array(true => 'a', 1 => 'b');
print_r($array);
?>




D


Question ID: 055217f24b50adda97e7e8268382779e [URL]
What is the output of the following code:
<?php
echo str_replace(array("Apple","Orange"), array("Orange","Apple"), "Oranges are orange and Apples are green");
?>




C


Question ID: 463a02ec00cf3d19d04196481a4d681f [URL]
Which of the following statements about Reflection are correct? [ Choose 2 ]




B, C


Question ID: e6e5fca7a00fc1eeb2bd49945edb7740 [URL]
Which DOM Element property provides a reference to the list of the element's children?

Question ID: c48fa64611835b82b3e4fa5f7ad3b3f3 [URL]
When you need to process the values of columns in a database, you should:




D


Question ID: e68cd789d05bff494ff566c60163fd1c [URL]
What PHP function can be used to remove a local file?





C

Question ID: acc73bcff4d41b5f510d234a2e51c2bf [URL]
Which of the following functions can help prevent session fixation vulnerabilities?




C

Question ID: 441300ee0e469e1c9f9afa52e2171d74 [URL]
When working with the MVC paradigm, the business logic should be implemented in which of the following components?



A


Question ID: 880759ed7f8a9d8eac43e5315b0a8bd7 [URL]
You want to present the following formatted number: "999.000.000,00". Which function call is correct?





E


Question ID: 99e6ff55f9cd1776f787a1f34f621aba [URL]
Can a private static member be accessed from a public static method of the same class?



C

Example:
class C {
    private static $x = 5;
   
    public static function getX() {
        return self::$x;
    }
}

echo C::getX(); // 5

Question ID: 023fd6681f4e02c6262b18fe25065fe8 [URL]
What is the difference between isset() and other is_*() functions (is_alpha(), is_number(), etc.)?




C

Language Construct - List of Keywords: http://php.net/manual/en/reserved.keywords.php

Question ID: 6bc989f914d1f134baea9d6ec0a2c4e2 [URL]
Consider the following script:
<html>
<head>
<title>
       This is a test script.
</title>
</head>
<body>
<?php
    echo 'This is some sample text';
?>
</body>
</html>




A


Question ID: 04180e9feb3191612c9c78eeea685d1c [URL]
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?




A


Question ID: 38870f473c2ef757db1229ddeaba6fc9 [URL]
Consider the following code:
<?php   
    $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?




A


Question ID: ce0e770c30c4a85eee8e67f6ca8c2941 [URL]
You work as a Web Developer for Remote Inc. What will be the output when you try to run the script below?
<?php
    $b = false;
    if($b = true)
      print("true");
    else
      print("false");
?>




B


Question ID: 9499bb72bfc50f07b97581ea746ab4ea [URL]
Which of the following options is/are correct regarding variable scopes in PHP?




C


Question ID: cf975d7ed82d6a7b29c5a3b5008fc099 [URL]
You run the following PHP script:
<?php
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.






A,C,D,E


Question ID: 9e7703566f58f482fce6c1b1df636ada [URL]
What is the result when the following PHP code involving a boolean cast is executed?
<?php
 var_dump( (bool) 5.8 );
?>




C

http://php.net/manual/en/language.types.boolean.php When converting to boolean, the following values are considered FALSE:
    the boolean FALSE itself
    the integer 0 (zero)
    the float 0.0 (zero)
    the empty string, and the string "0"
    an array with zero elements
    the special type NULL (including unset variables)
    SimpleXML objects created from empty tags
Every other value is considered TRUE (including any resource and NAN).

Question ID: f293cccce14830fd4a7e2fd8e97c29f7 [URL]
Which of the below provided options is correct regarding the below code?
<?php 
    $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); 
?>




D


Question ID: 44eb3ea4bc89587241f1b5f992126b74 [URL]
Which one of the following four logical operators of PHP is not binary?




B

Question ID: 4a5ee23df6777aa1f89b55272e1ed60b [URL]
What does the following function do, when passed two integer values for $p and $q?
<?php
function magic($p, $q) {  
     return ($q == 0) ? $p : magic($q, $p % $q);
}
?>




C


Question ID: 7a9e70b326bb94ceed7261c08ff2cf41 [URL]
Consider the following script:
<?php 
      echo 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?




B

In any operating system where older versions of glibc are present, the strtotime() function will not be able to identify dates prior to the UNIX period midnight UTC on January 1, 1970. Hence, the output of the script will be -1. Update: strtotime returns -1 in php version <= 5.1. In > versions, it would be false: http://php.net/manual/ru/function.strtotime.php

Question ID: d093318c919ce72869d1565e1c3eefd3 [URL]
Consider the following script:
<?php
    echo date("M-d-Y", mktime(0, 0, 0, 12, 32, 1995));
?>
What will be the output of the above script?




D

mktime: http://in2.php.net/mktime

Question ID: 59c9b2c5aafaf7dbbfa048ca3b6aee42 [URL]
Mark works as a Web Application Developer for Blue Solutions Inc. He writes the following code:
<?php
    $x =25;
    while($x<10) {
        $x--;
    }
    print ($x); 
?>
What will be the output when Mark tries to compile and execute the code?




A


Question ID: 00757b6d115299815f7f224c1078b528 [URL]
What does the following code snippet do?
$a = `ls -l`;




A

Execution Operators: http://php.net/manual/en/language.operators.execution.php The backtick operator makes it possible to execute a shell command and retrieve its output. So, $a will store the contents of the current working directory.

Question ID: c9fbc8565edfede93f4d89b7f02fd0e6 [URL]
John works as a Website Developer for PHPWEB Inc. He is using a Windows operating system and is also working on PHP engine 5.0. He develops the following script:
<?php
    echo date("M-d-Y", mktime(0, 0, 0, 12, 32, 1965));
?>
What will be the output of the above PHP script?




D

According to the scenario, John is working on a Windows operating system and his PHP engine version is 5.0, which is prior to PHP version 5.1. Hence, the output of the script will be -1 with a warning message, and it will not display Jan-01-1966.

Question ID: b53c50acdc2e8095310867c0443e568a [URL]
Which of the following types of errors halts the execution of a script and cannot be trapped?




A


Question ID: bb12d5c5aeb45375176a51fc5510a754 [URL]
Which of the following features are Undeprecated in PHP 5.3?




Question ID: f301380e7353912af2c1e5b15c66de56 [URL]
Consider the following PHP script:
<html>
<head>
<title>
    This is a test script.
</title>
</head>
<body>
<?php
    echo (int) ((0.1 + 0.7) * 10);
?>
</body>
</html>
What will be the output of the PHP script?




A

The expression ((0.1 + 0.7) * 10) should evaluate to 8. However, the output of the expression in the script evaluates to 7 because the PHP engine stores the value of the expression internally as 7.999999 instead of 7. When the fractional value is converted into an integer, the PHP engine simply truncates the fractional part. When the value is converted to int, PHP simply truncates away the fractional part, resulting in a rather significant error (12.5%, to be exact). Source: http://www.zendexam.com/question/19/consider-the-following-php-scriptwhat-will-be-the-output-of-the-php-script/

Question ID: 4594a8f5734ed79fbf73c884c40b217d [URL]
Which of the following statements explains the difference between print() and echo()?




D

Question ID: 3968400019bbcab10d476883b23a8e0b [URL]
What is the output of the following PHP code?
<?php
    define('FOO', 10);
    $array = array(10 => FOO,"FOO" => 20);
    print $array[$array[FOO]] * $array["FOO"];
?>




D


Question ID: 19391d2a2febd2249b7ff2a97c93337f [URL]
Mark works as a Web Developer for Unicorn Inc. He develops an application in PHP using the following code:
<?php
      switch(1) {
      case 1: print("Book Details"); 
      case 2: print("Book Author"); 
      default: print("Missing Book");
      }
?>
What will be the output of the script?





D


Question ID: 98b7614d3d0437c427c595cd3bbe92ea [URL]
Consider the following code:
<?php
    $x=0;
    $i;
    for($i=0;$i<5;$i++)
    {
        $x+=$i;
    }
    print($x);
?>
What will be the value of x?




A


Question ID: 27befef7bd898e74cf5646090d694cdb [URL]
Consider the following code:
<?php
function modvalue() {
       $a=20;
       $b=4;
       $c=$a%$b;
       print($c);
} 
modvalue();
?>
What will be the value of the variable c?




B


Question ID: 98c48989d2308bb53b5d6c255e0e5a60 [URL]
You run the following PHP script:
<?php
function calc() {
    $x=10;
    $b=++$x;
    print($b);
}
calc();
?>
What will be the value of the variable b?




A


Question ID: ec6d7ef6e12b6fde9df808512eeee730 [URL]
Which of the following are the core extensions? Each correct answer represents a complete solution. Choose all that apply.




A,B,D

There are many extensions (addons) to perform specific tasks. These extensions are added in the php.ini configuration file. There are a set of various PHP language elements called core extensions. These extensions are the part of the PHP core, such as arrays, classes, objects, etc. Answer option C is incorrect. PECL is a PHP extension community library. It is not the part of the core extension. Reference: http://php.net/manual/en/extensions.membership.php Source: http://www.zendexam.com/question/26/which-of-the-following-are-the-core-extensionseach-correct-answer-represents-a-complete-solution-choose-all-that-apply/

Question ID: 6ce76f8612c6e5d84ec002466fda6911 [URL]
You have been given a code snippet as follows:
$somearray = array("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?




B


Question ID: 8d6127533ad27db1b8b81844cd7202da [URL]
Which of the following code can be used to create case insensitive constant? (choose 2)
A.
<?php
define("GREETING","How are you today?",TRUE);
echo constant("greeting");
?>
B.
<?php
define("GREETING","How are you today?");
echo constant("greeting");
?>
C.
<?php
define("GREETING","How are you today?",FALSE);
echo constant("greeting");
?>
D.
<?php
define("GREETING","How are you today?",'USECASE');
echo constant("greeting");
?>




A,D

A is the answer, but how 'USE CASE' is parsed as true, so D also could be ok. constants: http://php.net/manual/en/language.constants.php

Question ID: 8ca864bf4193a9ad70b56ea9947fe45e [URL]
You run the following PHP script:
<php
     echo 0x33, ' birds sit on ', 022, ' trees.';
?>
What will be the output?




C


Question ID: 2b900a75131663ee21c62581709e52c1 [URL]
Consider the following code:
<?php
    $a;
    for($a=1;$a<=100;$a++) {
        if($a==50) {
            continue;
        }
        print($a);
    }
?>
What will be the output of the program?




A


Question ID: 18987fccf2630e296591777d591cbb03 [URL]
In which of the following ways does the identity operator === compare two values?




B


Question ID: 665ccfa5ef3f22d4dc0dbc1e94adc5cd [URL]
What is the output of the following code snippet?
<?php
$a = 20;
function myfunction($b) {
    $a = 30;
    global $a, $c;
    return $c = ($b + $a);
}
print myfunction(40) + $c;
?>




D


Question ID: 335c55fc397391406ce66ea43e2bb6b0 [URL]
Which of the following PHP variable names is not a valid variable name?




D


Question ID: d1471ac091bc1b055445b3eec2ff5400 [URL]
Assume that today is January 8th, 2013, 5:16:18 pm in MST time zone.
<?php
        echo date('l \t\h\e jS');
?>




B


Question ID: 7575926cd15aedf7bb4d4a4d727565b8 [URL]
What is the value of $x in the following code snippet?
<?php
    $x = 123 == 0123;
?>




A

123 is not equal to 0123, because 0123 is a octal notation. Integers: https://secure.php.net/manual/en/language.types.integer.php
$a = 1234; // decimal number
$a = -123; // a negative number
$a = 0123; // octal number (equivalent to 83 decimal)
$a = 0x1A; // hexadecimal number (equivalent to 26 decimal)
$a = 0b11111111; // binary number (equivalent to 255 decimal)

Question ID: d71422d5b4405dc289cdab1cdee6442f [URL]
Which of the following functions returns current Unix timestamp?




B


Question ID: 0aaa0ddfd0317b34c8f150551f771c06 [URL]
Which of the following files can be used to modify PHP configurations?




C


Question ID: 145d2561d454ec691e0a2c87d4f12a6a [URL]
Which of the following PHP directives will you use to display all errors except notices?




C


Question ID: 177fc40c71829f289fa05b8a7a84f211 [URL]
You run the following PHP script:
<?php
    $a=12;
    $b=11;   
    $a>$b ? print($a) : print($b);
?>




B


Question ID: e5af23cd2b63bb3561deae40b94fc0f0 [URL]
Which of the following is used to set a constant?




C


Question ID: 06d8f7d0fbc159b69310bf5f322cf0dc [URL]
What is the length of the hash generated by the crc32() crypto function?




A


Question ID: 21700b20f83399ad55078f5b933197a3 [URL]
Which of the following logical operators is an equivalence logical operator?




A


Question ID: 63e070418370fd55b7777bc377658648 [URL]
Which of the following is a magic constant?




B


Question ID: ac869b2b1c3366252828430a5b9bc357 [URL]
Which of the following operators has the highest precedence order?




D


Question ID: 99325893a71adc846cf99dc1a5d3be9d [URL]
Which of the following is related to APC (Alternative PHP Cache)?




B


Question ID: 59207e4860a2218017ed4c72f21e885a [URL]
Which of the following is NOT a strongly typed language?




C


Question ID: 370efc59595e990b4eca7dfbdfbb35ab [URL]
Which of the following is NOT a valid PHP variable name?




D


Question ID: 6352e15a10eeaab390bb82f278341a1e [URL]
You run the following PHP script:
<? 
    $a=20%-8;
    echo $a;
?>




A


Question ID: 15b9ad5b6c172d54bd040ab48ed071b5 [URL]
You run the following PHP script:
<? 
    echo (int) "1235Jason"; 
?>
What will be the output?




A


Question ID: 946eecb333d8f4efea8605cb42553587 [URL]
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?




A

Function odd() was never called, so $i is undefined and it will throw Notice, not error.

Question ID: 8c6a0c525cc2a70a786db79d3a777289 [URL]
You run the following PHP script:
<? 
    echo (int) "Jason 1235"; 
?>
What will be the output?




D


Question ID: 5f63389f99c1f5bb193adacfebf090af [URL]
You run the following PHP script:
<?php
    $sale = 200;
    $sale = $sale- + 1;
    echo $sale;
?>
What will be the output?




A


Question ID: 45e2e549bb0c7f0d31b7e0b2e56be294 [URL]
Which of the following functions allows you to stack several error handlers on top of each other?




D

Question ID: e607283af7922c6385d6d9f6ab143f27 [URL]
Consider the following code:
<?php
function add() {
       $x=10;
       $y=5;
       $x+=$y;
}
?>
What will be the value of x and y?




C


Question ID: 03a628f77afbaa151cfc459889cfc935 [URL]
You run the following PHP script:
<? 
    $a = "b";
    $b = 20;
    echo $$a;
?>
What will be the output?




D

Question ID: d2c60032146f6ab78291686719ca11e1 [URL]
You run the following PHP script:
<? 
    $a = "b";
    $b = 20;
    ${20} = $a;
    echo ${$b};
?>
What will be the output?




A


Question ID: e5054799131e521b1534fe193a4210c1 [URL]
You run the following script:
<?
    10 = $a;
    echo $a;
?>




A


Question ID: fd2a293f58bb09ceecf04a235f291c36 [URL]
You run the following PHP script:
<?php
    $num = -123test;
    $newnum = abs( $num );
    print $newnum;
?>
What will be the output?




B


Question ID: 29c0e17fcead68eb24a7608d1f1aaccb [URL]
Which of the following will you use to iterate a PHP associative array?




A


Question ID: 009bdd8b860c2cb61f727de891263a64 [URL]
You run the following script:
<?php
    $a = 6 - 10 % 4;
    echo $a;
?>
What will be the output?




D


Question ID: 7f4cf6da86ec79a55ac4cd4061be9c52 [URL]
You run the following script:
<?php
    $a=5 < 2;
    echo (gettype($a));
?>
What will be the output?




A


Question ID: 20d8f090533f114c21e7b89ed1bdb137 [URL]
Your application needs to handle file uploads performed with HTTP PUT. How can you retrieve this data?




A


Question ID: 2f394f15305e01cfa1a17599d9bf3d39 [URL]
How can the line on which HTTP headers were sent inside a script be determined?




A

headers_sent: http://php.net/manual/en/function.headers-sent.php headers_sent — Checks if or where headers have been sent

Question ID: bba7ac95f998aa501ebb6746a4edc427 [URL]
What is the output of the following code?
$a = 'myVar';

switch($a) {
    case 0:
        echo 'case 0';
    case 'myVar':
        echo 'case myVar';
    case 'nothing':
        echo 'case nothing';
}

case 0case myVarcase nothing

String 'myVar' when compared with integer 0 (first case) is converted to 0.

Question ID: 6bd852ee62293ddadac100dcc5c372f4 [URL]
Assume that you are using PHP s session management without cookies and want to make sure that session information does not get lost when redirecting the client to another URL. Which of the following functions do you need to achieve that? (Choose 3)





A,B,D


Question ID: f302cc879526a8d9e2ff093eb409bf8b [URL]
What is the best all-purpose way of comparing two strings?





D


Question ID: 1027737f72a95a9ae3a7ebadf8b92494 [URL]
What will be the net effect of running the following script on the $a string
<?php
$s = '<p>Hello</p>';
$ss = htmlentities($s);
echo $s;
?>





B


Question ID: 9fc3b4732f2287840068c036597f1599 [URL]
What is the output of the following code?
print strpos('Zend Certified Engineer', 116);





C

strpos: http://php.net/manual/en/function.strpos.php strpos — Find the position of the first occurrence of a substring in a string Description:
mixed strpos ( string $haystack , mixed $needle [, int $offset = 0 ] )
Important: If needle is not a string, it is converted to an integer and applied as the ordinal value of a character. In this case, 116 is an Ascii code equivalent to "t", position 8 in the string "Zend Certified Engineer".

Question ID: 44aa5cb21c1c728217a468501b7ac7e6 [URL]
What is the output of the following PHP script?
<?php
    for ($i = 5; ; $i++) {
        if ($i < 10) {
            break;
        }
    }
    echo $i;
?>
Enter the exact script output

5


Question ID: 778d4851ac95213915cc8cfec25c59d1 [URL]
What is the output of the following code?
$a = 1;
$b = 2;
$c = 3;
echo (++$a) + ($b++) + (++$c) + ($a++) + (++$b) + ($c++);

18

Answer: 2 + 2 + 4 + 2 + 4 + 4 = 18

Question ID: 8104741d123b52439145cf8d748afe53 [URL]
Which PHP extension can you use to connect to HTTP, SMTP or FTP servers?

sockets


Question ID: 7f4972bf2254ab39a1e853934da3eaf2 [URL]
What is the default timeout of a PHP session cookie?




D

http://php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime By default, the value of session.cookie_lifetime is 0

Question ID: aebf0fea98c06209db7c83ba538fbecb [URL]
What is the recommended setting for error_reporting for production servers?




A