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
How many elements does the array $pieces contain after the following piece of code has been executed?
$pieces = explode("/", "///");
Question: 4
What is the return value of the following code: substr_compare("foobar", "bar", 3);
Question: 5
The constructs for(), foreach(), and each() can all be used to iterate an object if the object...