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

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

csv格式文件生成實例

2019-11-10 20:26:08
字體:
來源:轉載
供稿:網友
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); } }
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 呼和浩特市| 益阳市| 霍邱县| 铜陵市| 区。| 明星| 志丹县| 如东县| 腾冲县| 凤山市| 宁城县| 锡林郭勒盟| 合川市| 崇州市| 淮阳县| 伊川县| 达拉特旗| 兰西县| 哈巴河县| 威信县| 南通市| 隆子县| 伽师县| 铁岭市| 隆安县| 星座| 长武县| 宁蒗| 英山县| 阿克苏市| 益阳市| 海原县| 武胜县| 宜昌市| 新蔡县| 稻城县| 汉阴县| 高平市| 中阳县| 大同县| 赞皇县|