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

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

csv格式文件生成實例

2019-11-10 18:13:43
字體:
來源:轉載
供稿:網友
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); } }
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 无极县| 清新县| 陆河县| 富顺县| 云梦县| 古田县| 汾西县| 霍山县| 房产| 惠州市| 深州市| 鄂温| 乐清市| 仲巴县| 射洪县| 武鸣县| 大厂| 临湘市| 墨江| 安阳市| 罗甸县| 金山区| 申扎县| 敖汉旗| 昌乐县| 扎囊县| 德格县| 格尔木市| 左贡县| 乳源| 隆尧县| 镇原县| 镇沅| 鄱阳县| 夏邑县| 长丰县| 仙桃市| 綦江县| 桃园县| 唐海县| 榆中县|