Zend Certified PHP Engineer (ZCPE) Practice Test 2025 – All-in-One Guide to Achieve Certification Success!

Image Description

Question: 1 / 400

What is the output of the given PHP code that creates a DOM document and loads an empty root element?

<root/>

<root></root>

<?xml version="1.0"?><root></root>

<?xml version="1.0"?><root/>

The output of the PHP code that creates a DOM document and loads an empty root element is correct in identifying that it includes the XML declaration followed by a self-closing root element.

When you create a new DOM document in PHP and add an empty root element to it, the default behavior is to also include the XML declaration at the start of the document. This declaration specifies the version of XML being used, which in this case is "1.0". Following that, since the root element is empty, it is represented as a self-closing tag, meaning that it does not have any child elements or text content inside.

In the case provided, the combination of the XML declaration and the self-closing root element accurately reflects the output format that PHP's DOMDocument would produce, hence producing the result: <?xml version="1.0"?><root/>.

Get further explanation with Examzify DeepDiveBeta
Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy