The constructs for(), foreach(), and each() can all be used to iterate an object if the object...
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() . ',';
}
Which PHP function sets a cookie and URL encodes its value when sending it to the browser?
Given a PHP value, which sample shows how to convert the value to JSON?
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)
What is the length of a string returned by: md5(rand(), TRUE);
What information can be used to reliably determine the type of an uploaded file?
What is the output of the following code?
$a = array('a', 'b'=>'c');
echo property_exists((object) $a, 'a')?'true':'false';
echo '-';
echo property_exists((object) $a, 'b')?'true':'false';
Which of the following is correct? (Choose 2)
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);
Which of the following is used to find all PHP files under a certain directory?
What will the following code print out?
$str = '✔ one of the following';
echo str_replace('✔', 'Check', $str);
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)
Consider the following XML code:
<books>
<book id="1">PHP 5.5 in 42 Hours
<book id="2">Learning PHP 5.5 The Hard Way
Which of the following SimpleXML calls prints the name of the second book?
(Let $xml = simplexml_load_file("books.xml"); .) (Choose 2)
What is the output of the following code?
var_dump(boolval([]));
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);
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?
What is the difference between "print" and "echo"?
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 PHP values may NOT be encoded to a JavaScript literal using PHP's ext/json capabilities?
Which of the following is an invalid DOM save method?
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;
}
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);
What content-type is required when sending an HTTP POST using JavaScript to ensure that PHP can access the data?
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);
What is the output of the following code?
function increment ($val)
{
$_GET['m'] = (int) $_GET['m'] + 1;
}
$_GET['m'] = 1;
echo $_GET['m'];
What method can be used to find the tag
What is the name of the key for the element in $_FILES['name'] that contains the provisional name of the uploaded file?
Which options do you have in PHP to set the expiry date of a session?
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');
Which one of the following XML declarations is NOT valid?
Which technique should be used to speed up joins without changing their results?
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);