Question: 1
Consider the following table data and PHP code, and assume that the database supports transactions. What is the outcome?
Table data (table name "users" with primary key "id"):
id name email
------- ----------- -------------------
1 anna alpha@example.com
2 betty beta@example.org
3 clara gamma@example.net
5 sue sigma@example.info
PHP code (assume the PDO connection is correctly established):
$dsn = 'mysql:host=localhost;dbname=exam';
$user = 'username';
$pass = '********';
$pdo = new PDO($dsn, $user, $pass);
try {
$pdo->exec("INSERT INTO users (id, name, email) VALUES (6, 'bill', 'delta@example.com')");
$pdo->begin();
$pdo->exec("INSERT INTO users (id, name, email) VALUES (7, 'john', 'epsilon@example.com')");
throw new Exception();
} catch (Exception $e) {
$pdo->rollBack();
}
Question: 2
How many elements does the array $pieces contain after the following piece of code has been executed?
$pieces = explode("/", "///");
Question: 3
The constructs for(), foreach(), and each() can all be used to iterate an object if the object...
Question: 4
After performing the following operations:
$a = array('a', 'b', 'c');
$a = array_keys(array_flip($a));
What will be the value of $a?
Question: 5
What is the output of the following code?
$a = 'a'; $b = 'b';
echo isset($c) ? $a.$b.$c : ($c = 'c').'d';