+ -
当前位置:首页 → 问答吧 → class

class

时间:2010-09-21

来源:互联网

<?php
class Hy{
        private $host;
        private $dbname;
        private $dbpwd;
        private $datable;
    function __construct($host="127.0.0.1",$dbname="root",$dbpwd="294442185",$datable="root")
    {
    $this->host=$host;
    $this->dbname=$dbname;
    $this->dbpwd=$dbpwd;
    $this->datable=$datable;
    }
    function conn(){
        mysql_connect($this->host,$this->dbname,$this->dbpwd)or die("Mysql服务器链接失败".mysql_error());
        }
        function conntable()
            {
                mysql_select_db($this->datable,$this->conn())or die("数据库链接失败".mysql_error()); //为什么这行出错 难道调用的链接数据库不对吗
        }
            function __destruct()
    {
                mysql_close($this->conn());
                }
}
$p1=new Hy();
echo $p1->conn();
?>

作者: heyongphp   发布时间: 2010-09-21

哈哈哈..

conn方法是什么东西。有返回值么

作者: cain   发布时间: 2010-09-21

相关阅读 更多

热门下载

更多