Limited-Time Offer: Enjoy 50% Savings! Coupon code: 50OFF Use it at checkout
Skip to content

Free Zend Certified Engineer 200-710 Exam Questions

Last updated: · 11 practice questions with answers and explanations

Page: 1 / 16 Total 232 questions

Want more questions? Get Premium Access.

Question 1

New Single answer

Topic: Data Format & Types

Skill tested: Assesses safe parsing of untrusted XML with the XML extension and libxml error handling.

A logistics service accepts XML documents from external partners. The current implementation calls `simplexml_load_string()` directly and occasionally emits parser warnings into an API response; malformed payloads also make the request fail unclearly. The service must reject malformed XML, keep diagnostics out of the response, and report parsing failure through its own controlled error path. Which implementation is the most appropriate?

Correct Answer: A. Enable internal libxml error handling, parse the string, inspect the returned value, collect errors as needed, then clear the error buffer and restore the previous error-handling state.
Explanation:

Internal libxml error handling lets the application capture parser diagnostics instead of emitting them as warnings, while the parser's return value can be checked for failure. The application can then produce a controlled response and clean up the error buffer and prior handling state. `LIBXML_NOERROR` merely suppresses reporting; it does not itself establish valid parsing or a clear failure path. `@` hides diagnostics but does not provide structured handling, and an empty valid document is not reliably distinguished that way. Recovery parsing can produce a modified document from malformed input, contrary to the requirement to reject it.

Question 2

New Single answer

Topic: Functions

Skill tested: Evaluates closure capture semantics for preserving per-iteration values in deferred callbacks.

A PHP service builds callbacks in a loop, then executes them later after the loop has finished. Each callback must retain the value associated with its own iteration; the callbacks must not share a mutable reference to the loop variable. The existing code uses `function () use (&$item)`, so every callback observes the final value. Which change provides the required behavior while keeping the closures otherwise unchanged?

Correct Answer: A. Capture `$item` by value with `use ($item)` when each closure is created.
Explanation:

A closure's `use ($item)` clause captures the variable's value at closure creation, so each iteration's callback retains its own value. Capturing by reference with `&$item` instead makes the callbacks refer to the same variable, whose value changes as the loop proceeds. `global` would introduce shared global state rather than a per-closure snapshot. A static closure cannot access `$item` unless it is explicitly captured and does not change reference semantics. Returning from the closure only occurs when it is invoked, after the loop.

Question 3

New Multiple answers

Topic: Web Features

Skill tested: Assesses secure PHP session configuration and session identifier renewal after authentication.

A customer portal uses PHP sessions for authenticated users. A security review found that the application accepts session identifiers supplied in URLs and keeps the same session ID after login, allowing a pre-authentication identifier to become authenticated. The portal must use cookies for session transport and reduce session-fixation risk without breaking the authenticated session. Which two changes best meet these requirements? Select TWO.

Correct Answer: A. Regenerate the session ID after successful authentication, deleting the old session data where appropriate.; D. Disable session ID acceptance from URLs, for example by setting `session.use_trans_sid=0`.
Explanation:

Disabling transparent session ID transport prevents the session identifier from being accepted through URLs, while regenerating the ID at the authentication boundary prevents an attacker-selected pre-login identifier from simply becoming the authenticated identifier. The old session data can be deleted when appropriate to avoid retaining the prior identifier. `HttpOnly` limits JavaScript access to the cookie but does not prevent fixation. Destroying the session on every request disrupts normal state and reusing an incoming ID defeats the objective. A URL parameter is not a secure session substitute.

Question 4

New Single answer

Topic: Object Oriented Programming

Skill tested: Tests how late static binding affects inherited static factory methods and subclass construction.

A library defines an abstract `Record` base class with a static factory method that constructs an object of the class on which the method was called. Several concrete record classes inherit the factory, and callers invoke `InvoiceRecord::fromArray($data)`. The factory currently returns a `Record` instance because its constructor expression uses `new self(...)`. The library must preserve the calling subclass without duplicating the factory in every subclass. What is the best correction?

Correct Answer: C. Replace `self` with `static` in the construction expression so late static binding selects the called class.
Explanation:

In an inherited static method, `self` refers to the class where the method is defined, whereas `static` uses late static binding and refers to the class named at the call site. Thus `new static(...)` allows the inherited factory to instantiate `InvoiceRecord` without duplicate methods. `parent` refers to a parent class, not the runtime subclass. Making the method non-static changes its calling model and does not solve construction of the called subclass. `__CLASS__` is also bound to the declaring class, not the runtime class.

Question 5

New Single answer

Topic: Security

Skill tested: Evaluates context-appropriate HTML output escaping to prevent cross-site scripting.

An administrative PHP page displays a partner-controlled label inside an HTML element's text content. The label may contain quotation marks, angle brackets, and characters from multiple languages. The application must preserve valid text while preventing the value from being interpreted as markup. Which output approach is most appropriate for this HTML text context?

Correct Answer: C. Pass the value through `htmlspecialchars()` with `ENT_QUOTES | ENT_SUBSTITUTE` and an explicitly selected UTF-8 encoding.
Explanation:

For HTML text content, `htmlspecialchars()` encodes the characters that can form markup delimiters; `ENT_QUOTES` also handles both quote types, and `ENT_SUBSTITUTE` avoids invalid-encoding failures. Explicitly selecting UTF-8 makes the encoding behavior predictable. Deleting all non-ASCII and punctuation damages legitimate multilingual labels and is not a robust encoding strategy. `addslashes()` is not HTML escaping and does not prevent markup interpretation. Relying on an implicit charset can create inconsistent output behavior.

Question 6

New Single answer

Topic: I/O

Skill tested: Assesses safe handling of uploaded files using PHP upload metadata and controlled destinations.

A PHP application receives user-submitted profile images. The upload form restricts file extensions in the browser, but the server must prevent path manipulation and must not trust the client-provided filename. Files should be stored under generated names in a directory outside the document root. Which server-side approach best satisfies these requirements?

Correct Answer: C. Check the upload error and size, validate the detected image type, generate a server-side filename, and move the temporary upload with `move_uploaded_file()` to the controlled directory.
Explanation:

PHP provides upload status and temporary-file metadata through `$_FILES`; validation should occur on the server, and `move_uploaded_file()` verifies that the source is a PHP upload. A generated name and a controlled destination avoid trusting client paths and reduce collisions or traversal risks. `basename()` does not make a client filename a trustworthy storage name, and `rename()` does not verify upload provenance. The submitted MIME type is client-controlled. Storing in the document root and trusting extensions leaves exposure if validation or server configuration is imperfect.

Question 7

New Single answer

Topic: Strings & Patterns

Skill tested: Evaluates use of PCRE anchors and delimiters to validate an entire input string.

A billing system accepts an identifier consisting of exactly eight uppercase ASCII letters followed by four digits. A developer uses `preg_match('/[A-Z]{8}[0-9]{4}/', $value)` and discovers that strings with extra characters are accepted. The system must reject any value containing a prefix or suffix beyond the required identifier. Which pattern change is the most appropriate?

Correct Answer: D. Use `^` and `$` anchors around the expression, with the intended newline behavior considered.
Explanation:

The original pattern can match a substring anywhere in the input. Anchoring the expression with `^` and `$` requires the match to cover the input's beginning and end, subject to PCRE's documented end-anchor behavior around a final newline; the application should choose anchors appropriate to its input policy. Word boundaries do not require the entire value to match, and can permit surrounding punctuation. Adding case-insensitivity weakens the uppercase requirement and still permits substring matches. The proposed NUL/control anchors do not express the intended whole-string validation.

Question 8

New Multiple answers

Topic: Databases & SQL

Skill tested: Assesses PDO prepared statements, parameter binding, and transaction rollback on failure.

A PHP order service writes an order header and multiple line items using PDO. The operations must be atomic: either the header and every line item are stored, or none are. Product identifiers and quantities come from the request and must not be interpolated into SQL. If any insert fails, the service must leave the database unchanged. Which two implementation practices meet these requirements? Select TWO.

Correct Answer: A. On an exception or failed operation, roll back the transaction before propagating or handling the failure.; C. Begin a transaction before inserting the header, execute all inserts with prepared statements and bound values, then commit only after every operation succeeds.
Explanation:

A transaction groups the header and line-item writes into one unit; committing only after all statements succeed preserves atomicity. Prepared statements with bound values separate SQL structure from request data and prevent those values from being treated as SQL syntax. Rolling back on failure prevents partial writes. Quoting and interpolating values is less robust than binding and, with per-item commits, defeats atomicity. Committing before line items leaves incomplete orders possible. A returned statement object alone does not establish that execution succeeded.

Question 9

New Single answer

Topic: Arrays

Skill tested: Tests safe iteration and mutation of associative PHP arrays without losing key associations.

A reporting job receives an associative array keyed by employee ID, with each value containing a score. It must produce a new array containing only scores above a threshold, preserving the original employee IDs and leaving the source array unchanged. Which approach most directly satisfies both requirements?

Correct Answer: A. Use `array_filter()` with a callback that tests each value and the `ARRAY_FILTER_USE_BOTH` flag only if the callback also needs the key; assign the returned array to a new variable.
Explanation:

`array_filter()` returns a filtered array and preserves the keys of retained elements, so assigning its result to a new variable leaves the source unchanged and keeps employee IDs associated with their scores. The callback can receive values alone, or both key and value with `ARRAY_FILTER_USE_BOTH` when the key is needed. `array_values()` discards the meaningful keys. Unsetting entries mutates the source. `array_map()` is designed to transform values and does not itself remove entries; merging does not reliably perform the required filtering.

Question 10

New Single answer

Topic: Error Handling

Skill tested: Assesses exception propagation and cleanup when a PHP operation fails inside a transaction.

A PHP import routine opens a database transaction, processes several records, and may throw a domain exception when a record fails validation. The caller is responsible for reporting the failure, while the routine must ensure the transaction is not left open with partial changes. The exception must retain its original type and message. Which implementation is most appropriate?

Correct Answer: D. Catch `Throwable`, roll back if the transaction is active, and rethrow the same caught object with `throw $e`.
Explanation:

Catching `Throwable` covers both exceptions and PHP errors, enabling cleanup for failures that occur during processing. Rolling back an active transaction prevents partial changes, and rethrowing the same object preserves its concrete type, message, and stack information for the caller. Returning `false` changes the signaling contract and catches only `Exception`, not all throwables. Committing after a failure preserves partial work and replacing the exception discards useful information. Error suppression does not provide transaction cleanup or reliable failure handling.

Question 11

New Multiple answers

Topic: PHP Basics

Skill tested: Evaluates PHP configuration choices for opcode caching and correct cache invalidation during deployment.

A production PHP application runs many identical requests and currently recompiles scripts on every request. The operations team wants to reduce repeated compilation overhead, retain predictable behavior across releases, and avoid stale bytecode when files change. The team can change PHP configuration and deployment procedures but cannot rewrite the application. Which two actions are the most appropriate? Select TWO.

Correct Answer: B. Enable and appropriately size OPcache for the production PHP runtime.; E. Configure OPcache to validate script timestamps at an interval suitable for the deployment model, or invalidate/reset the cache as part of deployment when timestamp checks are disabled.
Explanation:

OPcache stores compiled PHP bytecode in shared memory, avoiding repeated compilation for requests handled by the configured PHP runtime. Appropriate memory sizing helps accommodate the application's scripts. Timestamp validation controls how changes are detected; if validation is disabled for performance, deployment must explicitly invalidate or reset the relevant cache to prevent stale code. `display_errors` is unrelated and is generally unsuitable for production output. `opcache.enable_cli` applies to CLI, not all web requests, and `memory_limit` does not provide bytecode caching.