What is the output of the following code?
for ($i = 0; $i < 1.02; $i += 0.17) {
$a[$i] = $i;
}
echo count($a);
A. 0
B. 1
C. 2
D. 6
E. 7
Which methods can be used to overload object properties? (Choose 2)
A. set(), get()
B. __set(), __get()
C. __put(), __receive(), __exists()
D. set(), get(), isset()
E. __isset(), __unset()
What purpose do namespaces fulfill?
A. Encapsulation
B. Alternative to classes
C. Improved performance
D. All of the above
What will be the result of the following operation? array_combine(array("A","B","C"), array(1,2,3));
A. array("A","B","C",1,2,3)
B. array(1,2,3,"A","B",C")
C. array("A"=>1,"B"=>2,"C"=>3)
D. array(1=>"A",2=>"B",3=>"C")
E. array(1,2,3)
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]')`.
How many elements does the array $pieces contain after the following piece of code has been executed? $pieces = explode("/", "///");
A. 0
B. 3
C. 4
D. 5
Which of the following does NOT help to protect against session hijacking and fixation attacks?
A. Use SSL and set the $secure cookie parameter to true .
B. Set the session.use_only_cookies php.ini parameter to 1 .
C. Set the session.cookie_lifetime php.ini parameter to 0 .
D. Protect against XSS vulnerabilities in the application.
E. Rotate the session id on successful login and logout using session_regenerate_id()
When a query that is supposed to affect rows is executed as part of a transaction, and reports no affected rows, it could mean that: (Choose 2)
A. The transaction failed
B. The transaction affected no lines
C. The transaction was rolled back
D. The transaction was committed without error
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.
The following form is loaded in a recent browser and submitted, with the second select option selected:
In the server-side PHP code to deal with the form data, what is the value of $_POST['list'] ?
A. 1
B. 2
C. two
D. null