我的異常拓展

 

  1. <?php 
  2. /* 
  3.  * Created on 2011-5-16 
  4.  * 
  5.  * To change the template for this generated file go to 
  6.  * Window - Preferences - PHPeclipse - PHP - Code Templates 
  7.  */ 
  8.  
  9.  
  10. try{ 
  11.  
  12.     $conn=mysql_connect("lolhost","kakaxi",""); 
  13.     echo $conn
  14.     if(!$conn
  15.     { 
  16.         throw new mysql_exception("couldn't connect to database'"); 
  17.     } 
  18.  
  19.  
  20.  
  21. }catch(mysql_exception $e
  22.     echo $e->getMessage(); 
  23.     echo $e->getmysqlerror(); 
  24.  
  25. class mysql_exception extends Exception{ 
  26.  
  27.     protected $mysqlerror
  28.  
  29.     public function __construct($message=null,$code=0) 
  30.     { 
  31.         $this->mysqlerror=mysql_error(); 
  32.         parent::__construct($message,$code); 
  33.     } 
  34.  
  35.     public function getmysqlerror() 
  36.     { 
  37.         return $this->mysqlerror; 
  38.     } 
  39.  
  40.  
  41. ?> 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章