當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SplFileObject::isWritable方法代碼示例

本文整理匯總了PHP中SplFileObject::isWritable方法的典型用法代碼示例。如果您正苦於以下問題:PHP SplFileObject::isWritable方法的具體用法?PHP SplFileObject::isWritable怎麽用?PHP SplFileObject::isWritable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SplFileObject的用法示例。


在下文中一共展示了SplFileObject::isWritable方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __destruct

 /**
  * Saves the current connection to `$this->file` if set.
  */
 public function __destruct()
 {
     if (isset($this->file) && $this->file->isWritable()) {
         $this->file->ftruncate(0);
         $this->file->rewind();
         $this->file->fwrite($this->toJson());
     }
 }
開發者ID:dividebv,項目名稱:phpdivideiq,代碼行數:11,代碼來源:DivideIQ.php

示例2: testInit

 /**
  * @return      void
  */
 public function testInit()
 {
     $filePath = __DIR__ . '/example_write1.txt';
     $fileObject = new FileWriter($filePath);
     $this->assertEquals($filePath, $fileObject->getPathname());
     $this->assertTrue($fileObject->isWritable());
     $filePath = __DIR__ . '/example_write2.txt';
     $fileObject = new \SplFileObject($filePath, 'r+');
     $this->assertEquals($filePath, $fileObject->getPathname());
     $this->assertTrue($fileObject->isWritable());
 }
開發者ID:naucon,項目名稱:file,代碼行數:14,代碼來源:FileWriterTest.php

示例3: write

 public function write($filename = null, Config $config = null, $exclusiveLock = null)
 {
     if (null !== $filename) {
         $this->setFilename($filename);
     }
     if (null !== $config) {
         $this->setConfig($config);
     }
     if (null !== $exclusiveLock) {
         $this->setExclusiveLock($exclusiveLock);
     }
     if (null === $this->_filename) {
         require_once '/Exception/Exception.php';
         throw new MPFConfigException("沒有設置文件名");
     }
     if (null === $this->_filename) {
         require_once 'MPF/Core/Config/Exception.php';
         throw new MPFConfigException("沒有設置配置");
     }
     $data = $this->_config->toArray();
     $sectionName = $this->_config->getSectionName();
     if (is_string($sectionName)) {
         $data = array($sectionName => $data);
     }
     $arrayString = "<?php\n" . "return " . var_export($data, true) . ";\n";
     $flags = 0;
     if ($this->_exclusiveLock) {
         $flags |= LOCK_EX;
     }
     $file = new SplFileObject($this->_filename, 'w+');
     $file->setFlags($flags);
     if ($file->isWritable()) {
         $result = $file->fwrite($arrayString);
     } else {
         require_once 'MPF/Core/Config/Exception.php';
         throw new MPFConfigException("文件不可寫");
     }
     return $result;
 }
開發者ID:wangping1987,項目名稱:dhfriendluck,代碼行數:39,代碼來源:ArrayWrite.php

示例4: create

 public static function create($file, $data, $has_clumn_name = false)
 {
     touch($file);
     $file = new SplFileObject($file, 'w');
     if (count($data) > 0 && !$file->isWritable()) {
         delete($file);
         return false;
     }
     if ($has_clumn_name) {
         $file->fputcsv(array_keys($data[0]));
     }
     foreach ($data as $line) {
         $file->fputcsv($line);
     }
     return true;
 }
開發者ID:shogirin,項目名稱:php-util,代碼行數:16,代碼來源:csvdb.class.php

示例5: bindRspecTearDown

 /**
  * Build RSpec teardown
  * @TODO: Complete function comment
  *
  * @param SplFileObject $rspecFileObj The file object of the test suite
  *
  * @throws {BadMethodCallException} If the $rspecFileObj param, wich is an SplFileObject object, stands for a non writable file.
  *
  * @return Void
  */
 public function bindRspecTearDown($rspecFileObj)
 {
     if ($rspecFileObj->isWritable()) {
         $content = "    after(:all) do\n";
         $content .= "        @valid.teardown()\n";
         $content .= "    end\n\n";
         $rspecFileObj->fwrite($content);
     } else {
         throw new BadMethodCallException('Something went wrong when trying to write to test suite file "' . $this->_testSuiteFile . '".');
     }
 }
開發者ID:benm-stm,項目名稱:FireOpal,代碼行數:21,代碼來源:TestSuite.class.php


注:本文中的SplFileObject::isWritable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。