国产探花免费观看_亚洲丰满少妇自慰呻吟_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); } }
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 永泰县| 湘潭县| 甘孜| 长岭县| 双牌县| 仁怀市| 收藏| 遂昌县| 周口市| 洛阳市| 灵川县| 理塘县| 谷城县| 龙泉市| 灵台县| 澄城县| 恩平市| 蓝田县| 长汀县| 峨眉山市| 攀枝花市| 洱源县| 二连浩特市| 普宁市| 米泉市| 彰化县| 舒兰市| 阿拉善盟| 宁国市| 青田县| 平谷区| 巴彦县| 尖扎县| 纳雍县| 柳江县| 从江县| 项城市| 东至县| 江华| 舞阳县| 沙田区|