当前位置: 首页>>代码示例>>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;未经允许,请勿转载。