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

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

csv格式文件生成實例

2019-11-10 18:07:27
字體:
來源:轉載
供稿:網友
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); } }
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 临安市| 钟山县| 家居| 桃园县| 克山县| 厦门市| 九龙城区| 海原县| 思茅市| 武宣县| 甘孜| 鹤岗市| 平阴县| 三原县| 日土县| 自治县| 九龙城区| 疏附县| 昂仁县| 宁都县| 杭州市| 梓潼县| 乐清市| 宾阳县| 东丽区| 平果县| 蒲城县| 金川县| 松阳县| 新安县| 新建县| 沂南县| 平顺县| 大丰市| 太仆寺旗| 宁河县| 永嘉县| 宜城市| 策勒县| 桐城市| 安溪县|