<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ### 實例 ~~~ class FileException extends Exception{ public function getDetails() { switch($this->code){ case 0: return "沒有提供文件"; break; case 1: return "文件不存在"; break; case 2: return "不是一個文件"; break; case 3: return "文件不可寫"; break; case 4: return "非法文件的操作模式"; break; case 5: return "文件寫入失敗"; break; case 6: return "文件不能被關閉"; break; default: return "非法操作"; break; } } } class WriteDate{ private $_message = ''; private $file; public function __construct($filename = null, $mode = 'w') { $this->_message = "文件:" . $filename . ",模式:" . $mode; if(empty($filename)) throw new FileException($this->_message, 0); if(!file_exists($filename)) throw new FileException($this->_message, 1); if(!is_file($filename)) throw new FileException($this->_message, 2); if(!is_writeable($filename)) throw new FileException($this->_message, 3); if(!in_array($mode, ['w', 'w+', 'a', 'a+'])) throw new FileException($this->_message, 4); $this->file = fopen($filename, $mode); } public function write($data) { if(@!fwrite($this->file, $data . PHP_EOL)) throw new FileException($this->_message, 5); } public function close() { if($this->file){ if(@!fclose($this->file)) throw new FileException($this->_message,6); } } } ~~~ 測 ~~~ try{ $file = new WriteDate('./1.txt', 'w+'); //,假如文件不存在 . $file->write("Hello World"); } catch(FileException $e){ echo $e->getDetails(); } ~~~ 結果 ~~~ 文件不存在 //拋出異常,穩如文件存在,就會寫入Hello World ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看