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

巧用php類

2022-06-13   來源: PHP編程 

<?php
class db {
private $db;
const CONS=constroctor start;
const OVER=Class now over;
public function __construct() {

$this>db=mysql;
$this>show(self::CONS);
}
public function getDriver() {
$this>show($this>db);
}
private function show($param) {
echo $param
;
}
public function __destruct() {
$this>show(self::OVER);
}
}
<?php
require dbphp;

$db=new db();
$db>getDriver();
/*
will echo:
constroctor start
mysql
Class now over
*/ 待續

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