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;
}
Which of the following methods are available to limit the amount of resources available to PHP through php.ini? (Choose 2)
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);
How can you determine whether a PHP script has already sent cookies to the client?
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)
Which of the following expressions will evaluate to a random value from an array below?
$array = array("Sue","Mary","John","Anna");
How many elements does the array $pieces contain after the following piece of code has been executed?
$pieces = explode("/", "///");
Which MIME type is always sent by a client if a JPEG file is uploaded via HTTP?
Given the following code, what is correct?
function f(stdClass &$x = NULL) { $x = 42; }
$z = new stdClass;
f($z);
var_dump($z);
An HTML form has two submit buttons. After submitting the form, how can you determine with PHP which button was clicked?
What super-global should be used to access information about uploaded files via a POST request?
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();
}
An HTML form contains this form element:
The user clicks on the image to submit the form. How can you now access the relative coordinates of the mouse click?
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);
}
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');
What is the output of the following code?
$text = 'This is text';
$text1 = <<<'TEXT'
$text
TEXT;
$text2 = << $text1 TEXT; echo "$text2";
Under what condition may HTTP headers be set from PHP if there is content echoed prior to the header function being used?
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.
Which of the following techniques ensures that a value submitted in a form can only be yes or no ?
Which PHP function sets a cookie and URL encodes its value when sending it to the browser?
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?