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"));
?>
<?php
function convertSpace($string)
{
return str_replace("_", " ", $string);
}
$string = "Peter_is_a_great_guy!";
echo filter_var($string, FILTER_CALLBACK, array("options"=>"convertSpace"));
?>
A. Peter_is_a_great_guy!
B. Peterisagreatguy!
C. Peter is a great guy!
D. Error
Answer: Option C
Solution(By Examveda Team)
The code above converts all “_” to white spaces. Call the filter_var() function with the FILTER_CALLBACK filter and an array containing our function.Related Questions on PHP Filter
A. Only 2
B. 2 and 3
C. None of the mentioned
D. All of the mentioned
A. filter_var_array()
B. filter_var()
C. filter_input
D. filter_input_array
A. No output is returned
B. Integer is not valid
C. Integer is valid
D. Error
Join The Discussion