How to skip fatal error from PHP -
this demo code in line 6 there function find() function doesn't exist , when run file got error fatal error: phone call undefined function find() in c:\xampp18\htdocs\demo\exp.php on line 6 question is possible in php handle type error i.e. want print line 2: 5 after first if block. 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 idea. check whether find() 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; } ?> php
No comments:
Post a Comment