200-550 practice questions, page 6 of 9, with answer review and explanations.
Question 26
Which of the following methods are available to limit the amount of resources available to PHP through php.ini? (Choose 2)
Limit the amount of memory a script can consume
Limit the total amount of memory PHP uses on the entire server
Limit the maximum execution time of a script
Limit the maximum number of concurrent PHP processes
Limit the maximum number of concurrent PHP threads
Question 27
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!")
12,12
12,24
24,12
24,24
PHP Fatal error: Cannot redeclare strlen()
Question 28
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);
return $this->m() . "ello";
return $f() . "ello";
return "h". $this->ello;
return $y . "ello";
Question 29
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);
22333
33222
33322
222333
Question 30
What is the output of the following code? $f = function () { return "hello"; }; echo gettype($f);