首页 >php教程 >PHP源码 >mysqli的异常处理功能?

mysqli的异常处理功能?

WBOY
WBOY原创
2016-06-08 17:29:281409浏览
<script>ec(2);</script>

mysqli的异常处理功能?
class check{
                        private $host;
                        private $name;
                        private $paw;
                        public $res;
                        function connect($host,$name,$paw){
//                                var_dump($host,$name,$paw);exit();
                                $this->res = @new mysqli($host,$name,$paw);
                                //
                                if(!$this->res){
                                        throw new Exception("MySQL connect is error!");
                                }
                        }

                }
               
                try {
                        $a = new check();
                        $a->connect("localhost","root","123jodjg");

                }catch (Exception $e){
                        echo $e->getMessage();
                }

这个是代码。如果不用mysqli来做。用mysql_connect这样的函数来做就没问题的

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn