What is the output of the following code?
$a = 'a'; $b = 'b';
echo isset($c) ? $a.$b.$c : ($c = 'c').'d';
A. abc
B. cd
C. 0d
What is the output of the following code?
echo "1" + 2 * "0x02";
A. 1
B. 3
C. 5
D. 20
E. 7
Which of these elements can be encapsulated by namespaces and made accessible from the outside?
A. Only classes
B. Classes, functions and constants
C. Classes, functions, constants and variables
Which of the following PHP values may NOT be encoded to a JavaScript literal using PHP's ext/json capabilities?
A. 'Hello, world!'
B. function(){ alert("Hello, world!"); }
C. array('Hello, world!')
D. array('message' => 'Hello, world!')
Given the following code, what will the output be:
trait MyTrait {
private $abc = 1;
public function increment() {
$this->abc++;
}
public function getValue() {
return $this->abc;
}
}
class MyClass {
use MyTrait;
public function incrementBy2() {
$this->increment();
$this->abc++;
}
}
$c = new MyClass;
$c->incrementBy2();
var_dump($c->getValue());
A. Fatal error: Access to private variable MyTrait::$abc from context MyClass
B. Notice: Undefined property MyClass::$abc
C. int(2)
D. int(3)
E. NULL
Which of the following functions will allow identifying unique values inside an array?
A. array_unique_values
B. array_distinct
C. array_count_values
D. array_intersect
E. array_values
What is the preferred method for preventing SQL injection?
A. Always using prepared statements for all SQL queries.
B. Always using the available database-specific escaping functionality on all variables prior to building the SQL query.
C. Using addslashes() to escape variables to be used in a query.
D. Using htmlspecialchars() and the available database-specific escaping functionality to escape variables to be used in a query.
What types of HTTP authentication are supported by PHP? (Choose 2)
A. Basic
B. Advanced
C. Strict
D. Digest
E. Realm
What SimpleXML function is used to parse a file?
A. simplexml_load_file()
B. simplexml_load_string()
C. load()
D. loadFile()
E. loadXML()
F. None of the above.
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()
A. ""
B. "/wireless"
C. "wireless"
D. "/conf.d/wireless"
E. "/etc"