PHP MCQ Quiz Hub

PHP Mcq – Error Handling

Choose a topic to test your knowledge and improve your PHP skills

How many error levels are available in PHP?





✅ Correct Answer: 3

Which version of PHP introduced E_STRICT Error level?





✅ Correct Answer: 2

Say you want to report error concerned about fatal run-time, fatal compile-time error and core error which statement would you use?





✅ Correct Answer: 4

Which version introduced the function error_get_last()?





✅ Correct Answer: 3

Which of the following statements causes PHP to disregard repeated error messages that occur within the same file and on the same line?





✅ Correct Answer: 1

Which function initializes the constants necessary for using the openlog(), clodelog(), and syslog() functions?





✅ Correct Answer: 4

Which logging option’s description is if an error occurs when writing to the syslog, send output to the system console?





✅ Correct Answer: 1

Which function is responsible for sending a custom message to the system log?





✅ Correct Answer: 2

Which version of PHP was added with Exception handling?





✅ Correct Answer: 2

How many methods are available for the exception class?





✅ Correct Answer: 3

Which of the following is/are an external data? i) Cookies ii) Input data from a form iii) Server Variables iv) Web services data





✅ Correct Answer: 4

Which one of the following filter is used to filter several variables with the same or different filters?





✅ Correct Answer: 1

Which one of the following does not describe a validating filter?





✅ Correct Answer: 1

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"); ?>





✅ Correct Answer: 2

If the input variable is a string like this “http://www.saåånfoøøundry.com/”, the $url variable after the sanitizing will look like?





✅ Correct Answer: 4

What will be the output of the following PHP code? <?php $value = 'car'; $result = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); ?>





✅ Correct Answer: 3

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")); ?>





✅ Correct Answer: 3

PHP has long supported two regular expression implementations known as _______ and _______ i) Perl ii) PEAR iii) Pearl iv) POSIX





✅ Correct Answer: 3

[:alpha:] can also be specified as ________





✅ Correct Answer: 2

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!"; ?>





✅ Correct Answer: 2