Home » PHP » PHP Filters Advanced » Question
  1. What will be the output of the following PHP code?
    <?php
    function convertSpace($str)
    {
    return str_replace("_", " ", $str);
    }
    $str = "Interview_Mania_is_good_for_interview_preparation!";
    echo filter_var($str, FILTER_CALLBACK, array("options"=>"convertSpace"));
    ?>
    1. Error
    2. Interview_Mania_is_good_for_interview_preparation!
    3. Nothing
    4. InterviewManiaisgoodforinterviewpreparation!
    5. Interview Mania is good for interview preparation!
Correct Option: D

The code above converts all “_” to white spaces. Call the filter_var() function with the FILTER_CALLBACK filter and an array containing our function.



Your comments will be displayed only after manual approval.