Zend Certified PHP Engineer Practice Test 2025 – Complete Exam Prep

Question: 1 / 400

What output will the following code produce: if (!empty(EMPTY)) { if (!((boolean) _CONSTANT)) { print "One"; } } else if (constant('CONSTANT') == 1) { print "Two"; }?

One

Two

Parse Error

The code provided defines a sequence of logical conditions and attempts to use an undefined constant, which leads to a parse error.

When evaluating the code, the first condition checks if `EMPTY` is not empty. However, `EMPTY` is not defined as a constant in PHP, resulting in PHP treating it as a string with no defined value; thus, `empty(EMPTY)` would evaluate as false. Following this, the next condition is checking the boolean value of `_CONSTANT`, where `_CONSTANT` is not defined either.

Attempting to evaluate `((boolean) _CONSTANT)` will not yield a boolean statement because `_CONSTANT` is also considered as an undefined constant. Consequently, it leaves the code unable to determine what should be printed, leading to a parse error.

Parse errors in PHP occur when the code does not adhere to the language syntax rules, which is precisely the situation here due to the undefined constants being used. Therefore, the presence of these undefined constants results in a parse error, making it the expected output when this code is executed.

Get further explanation with Examzify DeepDiveBeta

Nothing

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy