php7中系統自帶異常類和自己創建異常類
1,系統自帶異常類 try catch
<?php
try{
throw new Exception('96net.com.cn',10);
}catch(Exception $e){
echo $e->getMessage();
echo $e->getCode();
}
2,自己創建異常類
<?php
class MyException extends Exception{
function demo(){
echo "dc3688.com";
}
}
try{
throw new MyException('96net.com.cn',10);
}catch(Exception $e){
echo $e->getMessage();
echo $e->getCode();
echo $e->demo();
}