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);
What is the output of the following code?
function increment ($val)
{
$_GET['m'] = (int) $_GET['m'] + 1;
}
$_GET['m'] = 1;
echo $_GET['m'];
When uploading a file to a PHP script using the HTTP PUT method, where would the file data be found?
Which of the following PHP values may NOT be encoded to a JavaScript literal using PHP's ext/json capabilities?
Consider the following code. Which keyword should be used in the line marked with "KEYWORD" instead of "self" to make this code work as intended?
abstract class Base {
protected function __construct() {
}
public static function create() {
return new self(); // KEYWORD
}
abstract function action();
}
class Item extends Base {
public function action() { echo __CLASS__; }
}
$item = Item::create();
$item->action(); // outputs "Item"
What is the output of this code?
$world = 'world';
echo <<<'TEXT'
hello $world
TEXT;
Which string will be returned by the following function call?
$test = '/etc/conf.d/wireless';
substr($test, strrpos($test, '/')); // note that strrpos() is being called, and not strpos()
PHP's array functions such as array_values() can be used on an object if the object...
Your public web application needs to provide access to binary files for registered users only. How would you achieve this?
Which of the following techniques ensures that a value submitted in a form can only be yes or no ?
What will the $array array contain at the end of this script?
function modifyArray (&$array)
{
foreach ($array as &$value)
{
$value = $value + 1;
}
$value = $value + 2;
}
$array = array (1, 2, 3);
modifyArray($array);
Which PHP function sets a cookie and URL encodes its value when sending it to the browser?
What will the following code print out?
$str = '✔ one of the following';
echo str_replace('✔', 'Check', $str);
Which of the following superglobals does not necessarily contain data from the client?
What is the output of the following code?
var_dump(boolval(new StdClass()));
Which of the following rules must every correct XML document adhere to? (Choose 2)
In the following code, which classes can be instantiated?
abstract class Graphics {
abstract function draw($im, $col);
}
abstract class Point1 extends Graphics {
public $x, $y;
function __construct($x, $y) {
$this->x = $x;
$this->y = $y;
}
function draw($im, $col) {
ImageSetPixel($im, $this->x, $this->y, $col);
}
}
class Point2 extends Point1 { }
abstract class Point3 extends Point2 { }
Which of the following may be used in conjunction with CASE inside a SWITCH statement?