FILL BLANK Which PHP function is used to validate whether the contents of $_FILES['name']['tmp_name'] have really been uploaded via HTTP?
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);
A. MyObject should extend class Closure
B. MyObject should implement interface Callable
C. MyObject should implement method __call
D. MyObject should implement method __invoke
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);
A. A GET request will be performed on http://example.com/submit.php
B. A POST request will be performed on http://example.com/submit.php
C. An error will be displayed
Which of the following may be used in conjunction with CASE inside a SWITCH statement?
A. A scalar
B. An expression
C. A boolean
D. All of the above
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);
A. 22333
B. 33222
C. 33322
D. 222333
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;
}
A. one
B. two
C. three
D. four
Which of the following statements is NOT correct?
A. Only methods can have type hints
B. Typehints can be optional
C. Typehints can be references
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. The PHP configuration option post_max_size is set to a value that is too small
B. The web server is using an incorrect encoding as part of the HTTP response sent to the client
C. The browser uses an incorrect encoding as part of the HTTP request sent to the server
D. The hidden form field MAX_FILE_SIZE was set to a value that is too small
E. PHP cannot process file uploads larger than 4 MB
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());
A. No changes needed, the code would output 2 as is
B. Line A, to: protected and$x = array();
C. Line B, to: public function andgetX() {
D. Line C, to: return and$this->x;
E. Line D, to: $a =and new A();
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)
A. strip_tags()
B. htmlentities()
C. htmltidy()
D. htmlspecialchars()
E. showhtml()