Bird
0
0

Which of the following is the correct way to set PHP to report all errors except notices?

easy📝 Syntax Q12 of 15
PHP - Error and Exception Handling
Which of the following is the correct way to set PHP to report all errors except notices?
Aerror_reporting(E_ALL & ~E_NOTICE);
Berror_reporting(E_ALL | E_NOTICE);
Cerror_reporting(E_ALL & E_NOTICE);
Derror_reporting(E_ALL ^ E_NOTICE);
Step-by-Step Solution
Solution:
  1. Step 1: Understand error_reporting flags

    E_ALL means all errors; ~E_NOTICE means exclude notices using bitwise NOT.
  2. Step 2: Analyze each option

    error_reporting(E_ALL & ~E_NOTICE); uses bitwise AND with NOT (~) to exclude notices correctly.
  3. Final Answer:

    error_reporting(E_ALL & ~E_NOTICE); -> Option A
  4. Quick Check:

    Exclude notices with & ~E_NOTICE [OK]
Quick Trick: Use & ~E_NOTICE to exclude notices from all errors [OK]
Common Mistakes:
  • Using | instead of & ~ to exclude errors
  • Confusing ^ (XOR) with exclusion
  • Using & E_NOTICE which includes only notices

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes