Php Exceptions And Error Handling(Engineering > Computer Science And Engineering > Php ) Questions and Answers

Question 1. How many error levels are available in PHP?
  1.    17
  2.    15
  3.    14
  4.    16
Explanation:-
Answer: Option D. -> 16

Question 2. Say you want to report error concerned about fatal run-time, fatal compile-time error and core error which statement would you use?
  1.    error_reporting = E_ERROR | E_PARSE | E_CORE_ERROR
  2.    error_reporting = E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR
  3.    error_reporting = E_ERROR | E_COMPILE_WARNING | E_CORE_ERROR
  4.    error_reporting = E_ALL
Explanation:-
Answer: Option B. -> error_reporting = E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR

Question 3. Which version of PHP introduced E_STRICT Error level?
  1.    PHP 5.2
  2.    PHP 5
  3.    PHP 5.3
  4.    PHP 4
Explanation:-
Answer: Option B. -> PHP 5

Question 4. What is the description of Error level E_ERROR?
  1.    Fatal run-time error
  2.    Compile-time error
  3.    Fatal Compile-time error
  4.    Near-fatal error
Explanation:-
Answer: Option A. -> Fatal run-time error

Question 5. Which character do the error_reporting directive use to represent the logical operator NOT?
  1.    ~
  2.    /
  3.    ^
  4.    !
Explanation:-
Answer: Option A. -> ~

Question 6. Which of the following statements causes PHP to disregard repeated error messages that occur within the same file and on the same line?
  1.    repeated_error_ignore
  2.    repeatedly_ignore_error
  3.    ignore_repeat_error
  4.    ignore_repeated_errors
Explanation:-
Answer: Option D. -> ignore_repeated_errors

Question 7. Which version introduced the function error_get_last()?
  1.    PHP 5.2
  2.    PHP 5
  3.    PHP 4
  4.    PHP 5.3
Explanation:-
Answer: Option A. -> PHP 5.2

Question 8. Which function initializes the constants necessary for using the openlog(), clodelog(), and syslog() functions?
  1.    define_log_variable()
  2.    log_variable()
  3.    define_syslog_variable()
  4.    define_variable()
Explanation:-
Answer: Option C. -> define_syslog_variable()

Question 9. Which logging option’s description is, if an error occurs when writing to the syslog, send output to the system console?
  1.    LOG_CONS
  2.    LOG_NDELAY
  3.    LOG_PERROR
  4.    LOG_ODELAY
Explanation:-
Answer: Option A. -> LOG_CONS

Question 10. Which function is responsible for sending a custom message to the system log?
  1.    sys_log()
  2.    log_system()
  3.    systemlog()
  4.    syslog()
Explanation:-
Answer: Option D. -> syslog()