如何捕获PHP 连接mysql错误
现在想对PHP连接mysql的代码做try,catch处理.
应该怎么做,当出现连接数据库失败的时候,返回一串自定义的内容.
try {<br /> $this->conn = new mysqli('192.168.1.101','root','root11','testdb1');<br /> }catch(Exception $e)<br /> {<br /> return $e-><i>·本2文来源gaodai$ma#com搞$代*码网2</i><strong>搞gaodaima代码</strong>getMessage();<br /> }