类与对象

 

<?php

class db {
    public $link;
    public function __construct(){
        $this->link = mysql_connect('127.0.0.1:3306','root','123456');
    }
}

$db = new db;

//操作
$sql = 'show databases';
$result = mysql_query($sql,$db->link);
var_dump(mysql_fetch_assoc($result));

?>

posted @ 2014-04-05 10:38  PHP学习者  阅读(92)  评论(0编辑  收藏  举报