Explore topic-wise MCQs in Php.

This section includes 4 Mcqs, each offering curated multiple-choice questions to sharpen your Php knowledge and support exam preparation. Choose a topic below to get started.

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

A. Error
B. Interview_Mania_is_good_for_interview_preparation!
C. Nothing
D. InterviewManiaisgoodforinterviewpreparation!
E. Interview Mania is good for interview preparation!
Answer» E. Interview Mania is good for interview preparation!
2.

What will be the output of the following PHP code?
<?php
$var = 'vehicle';
$Res = filter_var($var, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
echo $Res;
?>

A. Error
B. Null
C. True
D. False
E. None of these
Answer» C. True
3.

What will be the output of the following PHP code?
<?php
$n=256;
$int_opt = array("opt"=>array ("min"=>0, "max"=>256));
if (!filter_var($n, FILTER_VALIDATE_INT, $int_opt))
echo("Given Integer is not valid");
else
echo("Given Integer is valid");
?>

A. Given Integer is valid
B. Error
C. Given Integer is not valid
D. Nothing
E. None of these
Answer» B. Error
4.

What will be the output of the following PHP code?
<?php
$n = "102030";
if (!filter_var($n, FILTER_VALIDATE_INT))
echo("Given Integer is not valid");
else
echo("Above Integer is valid");
?>

A. Error
B. Nothing
C. Given Integer is valid
D. Given Integer is not valid
E. None of these
Answer» D. Given Integer is not valid