<?php
header('Content-type:text/html;charset=utf-8');
$a = 1;
$b = 2;
try {
//結果為真,設定異常資訊
if( $a < $b )
{
throw new Exception('a要大于b');
}
} catch (Exception $err) {
// 傳回異常資訊
echo $err->getMessage();
}
?>
<?php
header('Content-type:text/html;charset=utf-8');
$a = 1;
$b = 2;
try {
//結果為真,設定異常資訊
if( $a < $b )
{
throw new Exception('a要大于b');
}
} catch (Exception $err) {
// 傳回異常資訊
echo $err->getMessage();
}
?>