国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

csv格式文件生成實例

2019-11-10 17:29:39
字體:
來源:轉載
供稿:網友
PRotected function init() { try { $filename = 'accounts_'. date('Ymd') .'_'. time() .'.csv'; $db_file = DIR_DB .'/'. $filename; if ( ! file_exists(DIR_DB)) { if ( ! mkdir(DIR_DB, 0755, TRUE)) { throw new Exception('Can not make database dir:'. DIR_DB); } } $this->db = fopen($db_file, 'a+'); if ( ! $this->db) { throw new Exception('Can not open database file:'. $db_file); } $thead = array('ID', 'account', 'passWord', 'create_time'); if ( ! fputcsv($this->db, $thead)) { throw new Exception('Can not write table haeder to db. '); } } catch (Exception $e) { print $e->getMessage(); exit(); }public function run($todo_num) { $max_try_times = $todo_num * 2; try { $success_num = 0; $i = 0; $this->display('Start...'); while ($i < $max_try_times) { $account = '賬號'; $password = 'qwer1234'; $bool = $this->do_register($account, $password);//一個判斷 if ($bool) { $success_num++; $data = array($id, $account, $password, date('Y-m-d H:i:s')); $this->display(implode(', ', $data)); if ( ! fputcsv($this->db, $data)) { throw new Exception('Can not save account information to db. '); } } if ($success_num >= $todo_num) { break; } if (AWAIT_TIME > 0) { sleep(AWAIT_TIME); } $i++; } $this->display('DONE!'); } catch (Exception $e) { print $e->getMessage(); exit(); } }public function __destruct() { if ($this->db) { fclose($this->db); } }
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 铜鼓县| 福建省| 雅江县| 福安市| 紫阳县| 武夷山市| 郑州市| 军事| 公主岭市| 盘锦市| 抚顺市| 克山县| 山东省| 萝北县| 临桂县| 绥化市| 靖边县| 汤阴县| 新巴尔虎左旗| 五指山市| 兴文县| 阿鲁科尔沁旗| 灵丘县| 蒙山县| 鲁甸县| 博乐市| 乌审旗| 多伦县| 永济市| 潢川县| 汝阳县| 修水县| 华安县| 临西县| 海门市| 盘山县| 深州市| 泊头市| 孟村| 临夏县| 奉化市|