表A <?php // display warnings and errors error_reporting(E_WARNING | E_ERROR); // this will generate a notice, which will never be displayed echo $undefinedVar; // this will generate a fatal error, which will be displayed callUndefFunc(); ?>
<?php // turn off error display // no errors will be displayed error_reporting(0); // this will generate a notice echo $undefinedVar; // this will generate a fatal error callUndefFunc(); ?>
表C中的代码将所有错误信息甚至简单的注意事项都显示出来:
表C
<?php // all errors will be displayed error_reporting(E_ALL); // this will generate a notice echo $undefinedVar; // this will generate a fatal error callUndefFunc(); ?>
表D <?php // no errors will be displayed error_reporting(0); // start a task echo "Starting task..."; // call an undefined function // a fatal error occurs during task processing callMe(); // end the task echo "Successfully completed task..."; ?>