What is the output of this code?
$world = 'world';
echo <<<'TEXT'
hello $world
TEXT;
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 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();
Which of the following statements is true?
What is the difference between "print" and "echo"?
Which of the following is NOT true about PHP traits? (Choose 2)
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)
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];
Which of the following PHP values may NOT be encoded to a JavaScript literal using PHP's ext/json capabilities?
What can prevent PHP from being able to open a file on the hard drive (Choose 2)?
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 parts of the text are matched in the following regular expression?
$text = << The big bang bonged under the bung. EOT; preg_match_all('@b.n?g@', $text, $matches);
What would be the output of the following code?
namespace MyFramework\DB;
class MyClass {
static function myName() {
return __METHOD__;
}
}
print MyClass::myName();
What is the output of the following code?
function increment (&$val)
{
return $val + 1;
}
$a = 1;
echo increment ($a);
echo increment ($a);
What function can be used to retrieve an array of current options for a stream context?
Which of the following is NOT a valid function declaration?
You want to parse a URL into its single parts. Which function do you choose?
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);
Which of the following code snippets is correct? (Choose 2)
What does the __FILE__ constant contain?
What is the name of the header used to require HTTP authentication?
What will the following code print out?
$str = '✔ one of the following';
echo str_replace('✔', 'Check', $str);
How should you track errors on your production website?
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);
Which PHP function is used to validate whether the contents of $_FILES['name']['tmp_name'] have really been uploaded via HTTP?
An HTML form contains this form element:
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)
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?
The following form is loaded in a browser and submitted, with the checkbox activated:
In the server-side PHP code to deal with the form data, what is the value of $_POST['accept'] ?
The XML document below has been parsed into $xml via SimpleXML. How can the value of
Which of the following may be used in conjunction with CASE inside a SWITCH statement?
Transactions are used to...
Which PHP function sets a cookie whose value does not get URL encoded when sending it to the browser?
Which of the following does NOT help to protect against session hijacking and fixation attacks?