熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> PHP編程 >> 正文

如何使用php實現封裝數據庫的類文件

2022-06-13   來源: PHP編程 

  <?php

  class dbname{ private $localhost; private $root; private $pass; private $db_name; public function __construct($localhost$root$pass$db_name){ $this>localhost=$localhost; $this>root=$root; $this>pass=$pass; $this>db_name=$db_name; $this>query(); } private function query(){ mysql_connect($this>localhost$this>root$this>pass); mysql_select_db($this>db_name); mysql_query("set names utf"); } } ?>


From:http://tw.wingwit.com/Article/program/PHP/201311/21115.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.