function TriggerContent($c, $db){
try {
include 'pages/' . $c . '.php';
$content= getContent();
} catch (Exception $e){
$content = 'Error';
}
return $content;
}
我想要的是显示error
如果php文件不存在。 但它不起作用...为什么试试catch不工作?我究竟做错了什么? (php)
我在做什么错?
或者这只是不适合尝试赶上PHP?
使用'file_exists()'然后'throw'异常? – Qirel
getContent()抛出? – marekful
是否在里面创建变量try catch块在他们之外不可访问?我真的不知道, – Phiter