Php Filter(Engineering > Computer Science And Engineering > Php ) Questions and Answers
Question 1. Which one of the following does not describe a validating filter?
Strict format rules
Returns the expected type on success or FALSE on failure
Are used to allow or disallow specified characters in a string
Are used to validate user input
Explanation:-
Answer: Option C. -> Are used to allow or disallow specified characters in a string
Question 2. How many types of filtering are present in PHP?
None
2
4
3
Explanation:-
Answer: Option B. -> 2
Question 3. What will be the output of the following PHP code?$num = "123";if (!filter_var($num, FILTER_VALIDATE_INT))echo("Integer is not valid");elseecho("Integer is valid");
Integer is not valid
Error
Integer is valid
No output is returned
Explanation:-
Answer: Option C. -> Integer is valid
Question 4. Which one of the following filter is used to filter several variables with the same or different filters?
filter_var()
filter_input_array
filter_var_array()
filter_input
Explanation:-
Answer: Option C. -> filter_var_array()
Question 5. Which of the following is/are an external data?1. Cookies2. Input data from a form3. Server Variables4. Web services data
2 and 3
Only 2
None of the mentioned
All of the mentioned
Explanation:-
Answer: Option D. -> All of the mentioned
Question 6. What will be the output of the following PHP code?$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");elseecho("Integer is valid");
Error
No output is returned
Integer is not valid
Integer is valid
Explanation:-
Answer: Option C. -> Integer is not valid
Question 7. What will be the output of the following PHP code?$value = 'car';$result = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
TRUE
ERROR
FALSE
NULL
Explanation:-
Answer: Option D. -> NULL
Question 8. Which one of the following filter checks if variable of specified type exists?
filter_has_var
filter_id
filter_var_array
filter_var
Explanation:-
Answer: Option A. -> filter_has_var
Question 9. What will be the output of the following PHP code?function convertSpace($string){return str_replace("_", " ", $string);}$string = "Peter_is_a_great_guy!";echo filter_var($string, FILTER_CALLBACK, array("options"=>"convertSpace"));