This is a demo code in the line 6
there is a function find()
actually this function doesn't exist and when i run this file I got errorFatal error: Call to undefined function find() in C:\xampp18\htdocs\demo\exp.php on line 6
my question is that is this possible in PHP
to handle this type error i.e. want to print Line 2: 5
which is after the first if block. thanks in advance.
<?php
$a=10;
if(true)
{
echo "Line 1: ".$a/find();
}
if (true)
{
$b=2;
echo "<br>Line 2: ".$a/$b;
}
?>
that's not good idea. what about check whether find()
is exist or not using function_exists
. example:
<?php
$a=10;
if(true) {
echo "Line 1: " . (function_exists('find') ? $a/find() : $a);
}
if (true) {
$b=2;
echo "<br>Line 2: ".$a/$b;
}
?>