Try Catch cannot work with require_once in PHP?

前端 未结 3 913
傲寒
傲寒 2020-12-01 07:54

I can\'t do something like this ?

try {
    require_once( \'/includes/functions.php\' );      
}
catch(Exception $e) {    
    echo \"Message : \" . $e->g         


        
3条回答
  •  忘掉有多难
    2020-12-01 08:18

    This should work, but it is a bit of a hack.

    if(!@include_once("path/to/script.php")) {
        //Logic here
    }
    

提交回复
热议问题