Free 200-550 Exam Braindumps
Zend Certified PHP Engineer Questions 51–55 (page: 12)

Updated On: 9-Feb-2026

Consider the following table data and PHP code. 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 {
$cmd = "INSERT INTO users (id, name, email) VALUES (:id, :name, :email)";
$stmt = $pdo->prepare($cmd);
$stmt->bindValue('id', 1);
$stmt->bindValue('name', 'anna');
$stmt->bindValue('email', 'alpha@example.com');
$stmt->execute();
echo "Success!";
} catch (PDOException $e) {
echo "Failure!";
throw $e;
}

  1. The INSERT will succeed and the user will see the "Success!" message.
  2. The INSERT will fail because of a primary key violation, and the user will see the "Success!" message.
  3. The INSERT will fail because of a primary key violation, and the user will see a PDO warning message.
  4. The INSERT will fail because of a primary key violation, and the user will see the "Failure!" message.

Answer(s): B



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 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);
$cmd = "SELECT name, email FROM users LIMIT 1";
$stmt = $pdo->prepare($cmd);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_BOTH);
$row = $result[0];

  1. The value of $row is `array(0 => 'anna', 1 => 'alpha@example.com')`.
  2. The value of $row is `array('name' => 'anna', 'email' => 'alpha@example.com')`.
  3. The value of $row is `array(0 => 'anna', 'name' => 'anna', 1 => 'alpha@example.com', 'email' => 'alpha@example.com')`.
  4. The value of $result is `array('anna' => 'alpha@example.com')`.

Answer(s): C



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();
}

  1. The user 'bill' will be inserted, but the user 'john' will not be.
  2. Both user 'bill' and user 'john' will be inserted.
  3. Neither user 'bill' nor user 'john' will be inserted.
  4. The user 'bill' will not be inserted, but the user 'john' will be.

Answer(s): A



Given a PHP value, which sample shows how to convert the value to JSON?

  1. $string = json_encode($value);
  2. $string = Json::encode($value);
  3. $json = new Json($value); $string = $json->__toString();
  4. $value = (object) $value; $string = $value->__toJson();

Answer(s): A



Given a JSON-encoded string, which code sample correctly indicates how to decode the string to native PHP values?

  1. $json = new Json($jsonValue); $value = $json->decode();
  2. $value = Json::decode($jsonValue);
  3. $value = json_decode($jsonValue);
  4. $value = Json::fromJson($jsonValue);

Answer(s): C



Viewing page 12 of 46
Viewing questions 56 - 60 out of 223 questions


Post your Comments and Discuss Zend 200-550 exam prep with other Community members:

AI Tutor AI Tutor 👋 I’m here to help!