How many error levels are available in php programming?

PHP 7 Error Levels

There are sixteen different error levels [i.e. types] are available in PHP.

Error Levels in PHP

Usually, whenever the PHP engine encounters a problem that prevents a script from running properly it generate an error message. There are sixteen different error levels and each level is represented by an integer value and an associated constant. Here's a list of error levels:

Error LevelValueDescription
E_ERROR 1 A fatal run-time error, that can't be recovered from. The execution of the script is stopped immediately.
E_WARNING 2 A run-time warning. It is non-fatal and most errors tend to fall into this category. The execution of the script is not stopped.
E_PARSE 4 The compile-time parse error. Parse errors should only be generated by the parser.
E_NOTICE 8 A run-time notice indicating that the script encountered something that could possibly an error, although the situation could also occur when running a script normally.
E_CORE_ERROR 16 A fatal error that occur during the PHP's engine initial startup. This is like an E_ERROR, except it is generated by the core of PHP.
E_CORE_WARNING 32 A non-fatal error that occur during the PHP's engine initial startup. This is like an E_WARNING, except it is generated by the core of PHP.
E_COMPILE_ERROR 64 A fatal error that occur while the script was being compiled. This is like an E_ERROR, except it is generated by the Zend Scripting Engine.
E_COMPILE_WARNING 128 A non-fatal error occur while the script was being compiled. This is like an E_WARNING, except it is generated by the Zend Scripting Engine.
E_USER_ERROR 256 A fatal user-generated error message. This is like an E_ERROR, except it is generated by the PHP code using the function trigger_error[] rather than the PHP engine.
E_USER_WARNING 512 A non-fatal user-generated warning message. This is like an E_WARNING, except it is generated by the PHP code using the function trigger_error[] rather than the PHP engine
E_USER_NOTICE 1024 A user-generated notice message. This is like an E_NOTICE, except it is generated by the PHP code using the function trigger_error[] rather than the PHP engine.
E_STRICT 2048 Not strictly an error, but triggered whenever PHP encounters code that could lead to problems or forward incompatibilities
E_RECOVERABLE_ERROR 4096 A catchable fatal error. Although the error was fatal, it did not leave the PHP engine in an unstable state. If the error is not caught by a user defined error handler [see set_error_handler[]], the application aborts as it was an E_ERROR.
E_DEPRECATED 8192 A run-time notice indicating that the code will not work in future versions of PHP
E_USER_DEPRECATED 16384 A user-generated warning message. This is like an E_DEPRECATED, except it is generated by the PHP code using the function trigger_error[] rather than the PHP engine.
E_ALL 32767 All errors and warnings, except of level E_STRICT prior to PHP 5.4.0.

PHP 7 Error Levels

There are sixteen different error levels [i.e. types] are available in PHP.

Nội dung chính

  • PHP 7 Error Levels
  • Error Levels in PHP
  • How many error levels are available in PHP Mcq?
  • What type of errors can be occurred in PHP?
  • How show all errors in PHP?
  • What is the value of E_parse type of error?

Error Levels in PHP

Usually, whenever the PHP engine encounters a problem that prevents a script from running properly it generate an error message. There are sixteen different error levels and each level is represented by an integer value and an associated constant. Here's a list of error levels:

Error LevelValueDescription
E_ERROR 1 A fatal run-time error, that can't be recovered from. The execution of the script is stopped immediately.
E_WARNING 2 A run-time warning. It is non-fatal and most errors tend to fall into this category. The execution of the script is not stopped.
E_PARSE 4 The compile-time parse error. Parse errors should only be generated by the parser.
E_NOTICE 8 A run-time notice indicating that the script encountered something that could possibly an error, although the situation could also occur when running a script normally.
E_CORE_ERROR 16 A fatal error that occur during the PHP's engine initial startup. This is like an E_ERROR, except it is generated by the core of PHP.
E_CORE_WARNING 32 A non-fatal error that occur during the PHP's engine initial startup. This is like an E_WARNING, except it is generated by the core of PHP.
E_COMPILE_ERROR 64 A fatal error that occur while the script was being compiled. This is like an E_ERROR, except it is generated by the Zend Scripting Engine.
E_COMPILE_WARNING 128 A non-fatal error occur while the script was being compiled. This is like an E_WARNING, except it is generated by the Zend Scripting Engine.
E_USER_ERROR 256 A fatal user-generated error message. This is like an E_ERROR, except it is generated by the PHP code using the function trigger_error[] rather than the PHP engine.
E_USER_WARNING 512 A non-fatal user-generated warning message. This is like an E_WARNING, except it is generated by the PHP code using the function trigger_error[] rather than the PHP engine
E_USER_NOTICE 1024 A user-generated notice message. This is like an E_NOTICE, except it is generated by the PHP code using the function trigger_error[] rather than the PHP engine.
E_STRICT 2048 Not strictly an error, but triggered whenever PHP encounters code that could lead to problems or forward incompatibilities
E_RECOVERABLE_ERROR 4096 A catchable fatal error. Although the error was fatal, it did not leave the PHP engine in an unstable state. If the error is not caught by a user defined error handler [see set_error_handler[]], the application aborts as it was an E_ERROR.
E_DEPRECATED 8192 A run-time notice indicating that the code will not work in future versions of PHP
E_USER_DEPRECATED 16384 A user-generated warning message. This is like an E_DEPRECATED, except it is generated by the PHP code using the function trigger_error[] rather than the PHP engine.
E_ALL 32767 All errors and warnings, except of level E_STRICT prior to PHP 5.4.0.

This set of PHP Multiple Choice Questions & Answers [MCQs] focuses on “Error Handling”.

1. How many error levels are available in PHP?
a] 14
b] 15
c] 16
d] 17
View Answer

Answer: c
Explanation: Whenever the PHP engine encounters any problem that prevents a script from running properly it generates an error message. There are sixteen error levels and each level is represented by an integer value and an associated constant.

2. What is the description of Error level E_ERROR?
a] Fatal run-time error
b] Near-fatal error
c] Compile-time error
d] Fatal Compile-time error
View Answer

Answer: a
Explanation: E_ERROR is a fatal run-time error, that can’t be recovered from and the execution of the script is stopped immediately.

3. Which version of PHP introduced E_STRICT Error level?
a] PHP 4
b] PHP 5
c] PHP 5.2
d] PHP 5.3
View Answer

Answer: b
Explanation: E_STRICT is PHP version portability suggestions. It is not strictly an error, but it is triggered whenever PHP encounters code that could lead to problems or forward incompatibilities.

4. Which character does the error_reporting directive use to represent the logical operator NOT?
a] /
b] !
c] ~
d] ^
View Answer

Answer: c
Explanation: The twidle [~] character is used to represent the logical operator NOT.

5. Say you want to report error concerned about fatal run-time, fatal compile-time error and core error which statement would you use?
a] error_reporting = E_ALL
b] error_reporting = E_ERROR | E_PARSE | E_CORE_ERROR
c] error_reporting = E_ERROR | E_COMPILE_WARNING | E_CORE_ERROR
d] error_reporting = E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR
View Answer

Answer: d
Explanation: E_ERROR is a fatal run-time error, that can’t be recovered from. E_COMPILE_ERROR is a fatal error that occurs while the script was being compiled. And E_CORE_ERROR is a fatal error that occurs during the PHP’s engine initial startup.

6. Which version introduced the function error_get_last[]?
a] PHP 4
b] PHP 5
c] PHP 5.2
d] PHP 5.3
View Answer

Answer: c
Explanation: This function returns an associative array consisting of the type, message, file, and line of the last occurring error.

7. Which of the following statements causes PHP to disregard repeated error messages that occur within the same file and on the same line?
a] ignore_repeated_errors
b] ignore_repeat_error
c] repeatedly_ignore_error
d] repeated_error_ignore
View Answer

Answer: a
Explanation: ignore_repeated_errors will not log repeated messages. The repeated errors must occur in the same file on the same line unless ignore_repeated_source is set to true.

8. Which function initializes the constants necessary for using the openlog[], clodelog[], and syslog[] functions?
a] define_variable[]
b] define_log_variable[]
c] log_variable[]
d] define_syslog_variable[]
View Answer

Answer: d
Explanation: If you’re running PHP version 5.2.X or older, you need to execute this function before using any of the following logging functions.

9. Which logging option’s description is if an error occurs when writing to the syslog, send output to the system console?
a] LOG_CONS
b] LOG_NDELAY
c] LOG_ODELAY
d] LOG_PERROR
View Answer

Answer: a
Explanation: If there is an error while sending data to the system logger, LOG_CONS will write directly to the system console.

10. Which function is responsible for sending a custom message to the system log?
a] systemlog[]
b] syslog[]
c] log_system[]
d] sys_log[]
View Answer

Answer: b
Explanation: The function syslog[] generates a log message that will be distributed by the system logger.

Sanfoundry Global Education & Learning Series – PHP Programming.

To practice all questions on PHP Programming, here is complete set of 1000+ Multiple Choice Questions and Answers on PHP.

Next Steps:

  • Get Free Certificate of Merit in PHP Programming
  • Participate in PHP Programming Certification Contest
  • Become a Top Ranker in PHP Programming
  • Take PHP Programming Tests
  • Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
  • Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses.

How many error levels are available in PHP Mcq?

Explanation: Whenever the PHP engine encounters any problem that prevents a script from running properly it generates an error message. There are sixteen error levels and each level is represented by an integer value and an associated constant.

What type of errors can be occurred in PHP?

In PHP, mainly four types of errors are considered:.

Syntax Error or Parse Error..

Fatal Error..

Warning Error..

Notice Error..

How show all errors in PHP?

Quickly Show All PHP Errors The quickest way to display all php errors and warnings is to add these lines to your PHP code file: ini_set['display_errors', 1]; ini_set['display_startup_errors', 1]; error_reporting[E_ALL];

What is the value of E_parse type of error?

How many error levels are available in PHP Mcq?

Answer: B] PHP has a total of 16 error levels.

What are different types of errors available in PHP?

In PHP, mainly four types of errors are considered:.
Syntax Error or Parse Error..
Fatal Error..
Warning Error..
Notice Error..

How show all errors in PHP?

The quickest way to display all php errors and warnings is to add these lines to your PHP code file: ini_set['display_errors', 1]; ini_set['display_startup_errors', 1]; error_reporting[E_ALL]; The ini_set function will try to override the configuration found in your php.

What is error explain types of errors with it's code in PHP?

Error Report levels.

Chủ Đề