One common security risk is exposing error messages directly in the browser. Which PHP configuration directive can be disabled to prevent this?
A. html_display
B. error_reporting
C. display_errors
D. error_log
E. ignore_repeated_errors
Given the following code, how can we use both traits A and B in the same class? (select all that apply)
trait A {
public function hello() {
return "hello";
}
public function world() {
return "world";
}
}
trait B {
public function hello() {
return "Hello";
}
public function person($name) {
return ":$name";
}
}
A. Rename the A::hello() method to a different name using A::hello as helloA;
B. Use B::hello() instead of A 's version using B::hello insteadof A
C. Use B::hello() instead of A 's version using use B::hello
D. Rename the A::hello() method to a different name using A::hello renameto helloA;
E. None of the above (both can be used directly)
What super-global should be used to access information about uploaded files via a POST request?
A. $_SERVER
B. $_ENV
C. $_POST
D. $_FILES
E. $_GET
Consider the following table data and PHP code. What is a possible outcome?
Table data (table name "users" with primary key "id"): id name email
1 anna [email protected]
2 betty [email protected]
3 clara [email protected]
5 sue [email protected]
PHP code (assume the PDO connection is correctly established):
$dsn = 'mysql:host=localhost;dbname=exam';
$user = 'username';
$pass = '********';
$pdo = new PDO($dsn, $user, $pass);
$cmd = "SELECT name, email FROM users LIMIT 1";
$stmt = $pdo->prepare($cmd);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_BOTH);
$row = $result[0];
A. The value of $row is `array(0 => 'anna', 1 => '[email protected]')`.
B. The value of $row is `array('name' => 'anna', 'email' => '[email protected]')`.
C. The value of $row is `array(0 => 'anna', 'name' => 'anna', 1 => '[email protected]', 'email' => '[email protected]')`.
D. The value of $result is `array('anna' => '[email protected]')`.
What is the output of the following code?
class Base {
protected static function whoami() {
echo "Base ";
}
public static function whoareyou() {
static::whoami();
}
}
class A extends Base {
public static function test() {
Base::whoareyou();
self::whoareyou();
parent::whoareyou();
:whoareyou();
static::whoareyou();
}
public static function whoami() {
echo "A ";
}
}
class B extends A {
public static function whoami() {
echo "B ";
}
}
:test();
A. B B B B B
B. Base A Base A B
C. Base B B A B
D. Base B A A B
Given a JSON-encoded string, which code sample correctly indicates how to decode the string to native PHP values?
A. $json = new Json($jsonValue); $value = $json->decode();
B. $value = Json::decode($jsonValue);
C. $value = json_decode($jsonValue);
D. $value = Json::fromJson($jsonValue);
Which of the following filtering techniques prevents all cross-site scripting (XSS) vulnerabilities?
A. Strip all occurrences of the string