construct destruct编码
来源:互联网 发布:叙利亚政府军 知乎 编辑:程序博客网 时间:2024/06/10 15:21
<?php/** * 清晰的认识__construct() __destruct */class Example { public static $link; //在类实例化的时候自动加载__construct这个方法 public function __construct($localhost, $username, $password, $db) { self::$link = mysql_connect($localhost, $username, $password); if (mysql_errno()) { die('错误:' . mysql_error()); } mysql_set_charset('utf8'); mysql_select_db($db); } /** * 通过__construct链接好数据库然后执行sql语句...... */ //当类需要被删除或者销毁这个类的时候自动加载__destruct这个方法 public function __destruct() { echo '<pre>'; var_dump(self::$link); mysql_close(self::$link); var_dump(self::$link); }}$mysql = new Example('localhost', 'root', 'root', 'test');
0 0
- construct destruct编码
- 关于对象的construct与destruct
- How to construct/destruct before/after main()
- 关于对象的construct与destruct
- (大卫的阅读笔记)关于对象的construct与destruct
- (大卫的阅读笔记)关于对象的construct与destruct
- 全局对象在程序进入main之前construct, 离开main后destruct
- 全局对象在程序进入main之前construct, 离开main后destruct
- 全局对象在程序进入main之前construct, 离开main后destruct
- C++ - 派生类(derived class) 的 构造(construct) 和 析构(destruct)顺序 详解
- C++ - 虚继承(virtual inheritance)的构造(construct)和析构(destruct)顺序
- destruct.cpp
- PHP----DESTRUCT
- PHP destruct 作用
- construct
- php笔记_autoload call clone destruct
- c++继续学习 virtual Destruct function (虚析构函数)
- construct function
- [Paper Reading] Attention to Scale: Scale-aware Semantic Image Segmentation
- HDU1232/NYOJ608 畅通工程 并查集
- 【详细解析】字符串匹配的KMP算法
- android 三级缓存 简介
- 为什么他们都愿意投资Oracle认证?
- construct destruct编码
- 中国这10家慕课网站,您需要知道!
- 自然语言处理之:文本分析算法
- angularjs的监听方法$watch、$watchGrou、$watchCollection的使用方法
- 学习vue.js初识npm,webpack,CommonJS,AMD与CMD
- 关于jeeplus
- Zookeeper安装和使用
- UIStoryboard
- Android中向外部存储读写非字符串类数据