Home
MCQS
PHP MCQ Quiz Hub
PHP Mcq – Error Handling
Choose a topic to test your knowledge and improve your PHP skills
1. How many error levels are available in PHP?
14
15
16
17
2. Which version of PHP introduced E_STRICT Error level?
PHP 4
PHP 5
PHP 5.2
PHP 5.3
3. 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
error_reporting = E_ERROR | E_PARSE | E_CORE_ERROR
error_reporting = E_ERROR | E_COMPILE_WARNING | E_CORE_ERROR
error_reporting = E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR
4. Which version introduced the function error_get_last()?
PHP 4
PHP 5
PHP 5.2
PHP 5.3
5. Which of the following statements causes PHP to disregard repeated error messages that occur within the same file and on the same line?
ignore_repeated_errors
ignore_repeat_error
repeatedly_ignore_error
repeated_error_ignore
6. Which function initializes the constants necessary for using the openlog(), clodelog(), and syslog() functions?
define_variable()
define_log_variable()
log_variable()
define_syslog_variable()
7. Which logging option’s description is if an error occurs when writing to the syslog, send output to the system console?
LOG_CONS
LOG_NDELAY
LOG_ODELAY
LOG_PERROR
8. Which function is responsible for sending a custom message to the system log?
systemlog()
syslog()
log_system()
sys_log()
9. Which version of PHP was added with Exception handling?
PHP 4
PHP 5
PHP 5.3
PHP 6
10. How many methods are available for the exception class?
5
6
7
8
11. Which of the following is/are an external data? i) Cookies ii) Input data from a form iii) Server Variables iv) Web services data
Only ii)
ii) and iii)
Only iii)
i), ii), iii) and iv)
12. Which one of the following filter is used to filter several variables with the same or different filters?
filter_var_array()
filter_var()
filter_input
filter_input_array
13. Which one of the following does not describe a validating filter?
Are used to allow or disallow specific characters in a string
Are used to validate user input
Strict format rules
Returns the expected type on success or FALSE on failure
14. What will be the output of the following PHP code? <?php $var=300; $int_options = array("options"=>array ("min_range"=>0, "max_range"=>256)); if (!filter_var($var, FILTER_VALIDATE_INT, $int_options)) echo("Integer is not valid"); else echo("Integer is valid"); ?>
No output is returned b) c) d)
Integer is not valid
Integer is valid
Error
15. If the input variable is a string like this “http://www.saåånfoøøundry.com/”, the $url variable after the sanitizing will look like?
http://www.saåånfoøøundry.com/
http://www.saaanfoooundry.com/
http://www.saånfoøundry.com/
https://www.sanfoundry.com/
16. What will be the output of the following PHP code? <?php $value = 'car'; $result = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); ?>
FALSE
TRUE
NULL
fERROR
17. What will be the output of the following PHP code? <?php function convertSpace($string) { return str_replace("_", " ", $string); } $string = "Peter_is_a_great_guy!"; echo filter_var($string, FILTER_CALLBACK, array("options"=>"convertSpace")); ?>
Peter_is_a_great_guy!
Peterisagreatguy
Peter is a great guy!
Error
18. PHP has long supported two regular expression implementations known as _______ and _______ i) Perl ii) PEAR iii) Pearl iv) POSIX
i) and ii)
ii) and iv)
i) and iv)
ii) and iii)
19. [:alpha:] can also be specified as ________
[A-Za-z0-9]
[A-za-z]
[A-z]
[a-z]
20. What will be the output of the following PHP code? <?php $username = "jasoN"; if (ereg("([^a-z])",$username)) echo "Username must be all lowercase!"; else echo "Username is all lowercase!"; ?>
Error
Username must be all lowercase!
Username is all lowercase!
No Output is returned
Submit