Zend Certified PHP Engineer (ZCPE) Practice Test

Question: 1 / 400

How do you initiate error reporting in PHP?

By using error_report(E_ALL)

By using error_reporting(E_ALL) and ini_set('display_errors', 1)

Initiating error reporting in PHP effectively involves both setting the appropriate error reporting level and ensuring that errors are visible during the execution of scripts, especially in a development environment.

The correct approach of using error_reporting(E_ALL) and ini_set('display_errors', 1) does exactly that. The function error_reporting(E_ALL) sets the error reporting level to E_ALL, which means all errors, warnings, and notices will be reported. This is crucial for debugging and development stages when you want to catch all possible issues in your code.

The function ini_set('display_errors', 1) then modifies the configuration at runtime, instructing PHP to display the errors directly to the output. This is particularly useful in development as it helps the developer see problems immediately, allowing for quicker fixes. In a production environment, it's common to turn off error display to prevent revealing sensitive information to users, which is where other methods of logging errors would come into play instead.

While there are other methods mentioned in the choices, they do not combine both the reporting level setting and the display configuration in a single line, making option B the most comprehensive and effective means of initiating error reporting in a PHP environment.

Get further explanation with Examzify DeepDiveBeta

By setting display_errors = On in the php.ini file

By calling log_errors()

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy