当前位置: 首页>>代码示例>>PHP>>正文


PHP FileUtil::getContents方法代码示例

本文整理汇总了PHP中FileUtil::getContents方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtil::getContents方法的具体用法?PHP FileUtil::getContents怎么用?PHP FileUtil::getContents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileUtil的用法示例。


在下文中一共展示了FileUtil::getContents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: appending

 public function appending()
 {
     with($stream = new FileOutputStream($this->file, true));
     $stream->write('!');
     $this->file->close();
     $this->assertEquals('Created by FileOutputStreamTest!', FileUtil::getContents($this->file));
 }
开发者ID:xp-framework,项目名称:core,代码行数:7,代码来源:FileOutputStreamTest.class.php

示例2: fetchWsdl

 public function fetchWsdl()
 {
     if (0 == strncmp('https://', $this->uri, 8) || 0 == strncmp('http://', $this->uri, 7)) {
         return HttpUtil::get(new HttpConnection(new URL($this->uri)));
     } else {
         return FileUtil::getContents(new File($this->uri));
     }
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:8,代码来源:Generator.class.php

示例3: getContent

 /**
  * Retrieve contents of errordocument
  *
  * @return  string content
  */
 public function getContent()
 {
     try {
         $contents = FileUtil::getContents(new File($this->filename));
     } catch (Exception $e) {
         $this->message .= $e->toString();
         $contents = '<xp:value-of select="reason"/>';
     }
     return str_replace('<xp:value-of select="reason"/>', $this->message, $contents);
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:15,代码来源:ErrorDocument.class.php

示例4: get_contents_read_returns_less_than_size

 public function get_contents_read_returns_less_than_size()
 {
     $data = 'Test';
     $f = newinstance('io.Stream', array(), '{
     public function read($size= 4096) { return parent::read(min(1, $size)); }
   }');
     $f->open(STREAM_MODE_WRITE);
     $f->write($data);
     $f->close();
     $this->assertEquals($data, FileUtil::getContents($f));
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:11,代码来源:FileUtilTest.class.php

示例5: fetch

 /**
  * Fetch data
  *
  * @param   string name
  * @return  string data
  */
 protected function fetch($name)
 {
     return FileUtil::getContents(new File($this->path, $name));
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:10,代码来源:FileSystemStorage.class.php

示例6: addFile

 /**
  * Add a file
  *
  * @param   string id the id under which this entry will be located
  * @param   io.File file
  */
 public function addFile($id, $file)
 {
     $bytes = FileUtil::getContents($file);
     $this->_index[$id] = array(strlen($bytes), -1, $bytes);
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:11,代码来源:Archive.class.php

示例7: fromFile

 /**
  * Construct an XML tree from a file.
  *
  * <code>
  *   $tree= Tree::fromFile(new File('foo.xml'));
  * </code>
  *
  * @param   io.File file
  * @param   string c default __CLASS__ class name
  * @return  xml.Tree
  * @throws  xml.XMLFormatException in case of a parser error
  * @throws  io.IOException in case reading the file fails
  */
 public static function fromFile($file, $c = __CLASS__)
 {
     $parser = new XMLParser();
     $tree = new $c();
     $parser->setCallback($tree);
     $parser->parse(FileUtil::getContents($file));
     // Fetch actual encoding from parser
     $tree->setEncoding($parser->getEncoding());
     delete($parser);
     return $tree;
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:24,代码来源:Tree.class.php

示例8: testGetContents

 public function testGetContents()
 {
     // With both methods:
     $this->assertTrue((bool) FileUtil::getContents('http://google.com'));
     FileUtil::$alwaysCurl = true;
     $this->assertTrue((bool) FileUtil::getContents('http://google.com'));
     FileUtil::$alwaysCurl = false;
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:8,代码来源:FileUtilTest.php

示例9: get_contents

 public function get_contents()
 {
     $f = new File(Streams::readableFd(new MemoryInputStream('Test')));
     $this->assertEquals('Test', FileUtil::getContents($f));
 }
开发者ID:xp-framework,项目名称:core,代码行数:5,代码来源:FileUtilTest.class.php

示例10: updateUpdater

 /**
  * In which the updater downloads a new version of itself.
  * 
  * @param type $updaterCheck New version of the update utility
  * @return array
  */
 public function updateUpdater($updaterCheck)
 {
     if (version_compare($this->configVars['updaterVersion'], $updaterCheck) >= 0) {
         return array();
     }
     $updaterFiles = $this->updaterFiles;
     // Retrieve the update package contents' files' digests:
     $md5sums_content = FileUtil::getContents($this->updateServer . '/' . $this->getUpdateDataRoute($this->configVars['updaterVersion']) . '/contents.md5');
     // If there's an error on the server end the response will be a JSON
     $tryJson = json_decode($md5sums_content, 1);
     if (!(bool) $md5sums_content) {
         $admin = CActiveRecord::model('Admin')->findByPk(1);
         if ($this->scenario === 'upgrade' && isset($admin) && empty($admin->unique_key)) {
             $updaterSettingsLink = CHtml::link(Yii::t('admin', 'Updater Settings page'), array('admin/updaterSettings'));
             throw new CException(Yii::t('admin', 'You must first set a product key on the ' . $updaterSettingsLink));
         } else {
             throw new CException(Yii::t('admin', 'Unknown update server error.'), self::ERR_UPSERVER);
         }
     } else {
         if (is_array($tryJson)) {
             // License key error
             if (isset($tryJson['errors'])) {
                 throw new CException($tryJson['errors']);
             } else {
                 throw new CException(Yii::t('admin', 'Unknown update server error.') . ' ' . $md5sums_content);
             }
         }
     }
     preg_match_all(':^(?<md5sum>[a-f0-9]{32})\\s+source/protected/(?<filename>\\S.*)$:m', $md5sums_content, $md5s);
     $md5sums = array();
     for ($i = 0; $i < count($md5s[0]); $i++) {
         $md5sums[$md5s['md5sum'][$i]] = $md5s['filename'][$i];
     }
     // These are the files that need to be downloaded -- only those which have changed:
     $updaterFiles = array_intersect($md5sums, $updaterFiles);
     // Try to retrieve the files:
     $failed2Retrieve = array();
     foreach ($updaterFiles as $md5 => $file) {
         $pass = 0;
         $tries = 0;
         $downloadedFile = FileUtil::relpath(implode(DIRECTORY_SEPARATOR, array($this->webRoot, self::TMP_DIR, 'protected', FileUtil::rpath($file))), $this->thisPath . DIRECTORY_SEPARATOR);
         while (!$pass && $tries < 2) {
             $remoteFile = $this->updateServer . '/' . $this->sourceFileRoute . "/protected/{$file}";
             try {
                 $this->downloadSourceFile("protected/{$file}");
             } catch (Exception $e) {
                 break;
             }
             // Only call it done if it's intact and ready for use:
             $pass = md5_file($downloadedFile) == $md5;
             $tries++;
         }
         if (!$pass) {
             $failed2Retrieve[] = "protected/{$file}";
         }
     }
     $failedDownload = (bool) count($failed2Retrieve);
     // Copy the files into the live install
     if (!$failedDownload && (bool) count($updaterFiles)) {
         $this->applyFiles(self::TMP_DIR);
         // Remove the temporary directory:
         FileUtil::rrmdir($this->webRoot . DIRECTORY_SEPARATOR . self::TMP_DIR);
     } else {
         $errorResponse = json_decode($md5sums_content, 1);
         if (isset($errorResponse['errors'])) {
             throw new CException($errorResponse['errors']);
         }
     }
     // Write the new updater version into the configuration; else
     // the app will get stuck in a redirect loop
     if (!$failedDownload) {
         $this->regenerateConfig(Null, $updaterCheck, Null);
     }
     return $failed2Retrieve;
 }
开发者ID:keyeMyria,项目名称:CRM,代码行数:81,代码来源:UpdaterBehavior.php

示例11: fromFile

 /**
  * Create a new checksum from a file object
  *
  * @param   io.File file
  * @return  security.checksum.CRC16
  */
 public static function fromFile($file)
 {
     return CRC16::fromString(FileUtil::getContents($file));
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:10,代码来源:CRC16.class.php

示例12: load

 /**
  * Load an image
  *
  * @param   peer.URL source
  * @return  string[2] data and contenttype
  */
 public function load($source)
 {
     return array(FileUtil::getContents(new File($source->getURL())), MimeType::getByFilename($source->getURL()));
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:10,代码来源:FilesystemImageLoader.class.php

示例13: reloadConfiguration

 /**
  * Reload Bot configuration
  *
  */
 public function reloadConfiguration()
 {
     $this->config->reset();
     $this->lists = array();
     // Set base directory for lists relative to that of the config file's
     $base = dirname($this->config->getFilename()) . DIRECTORY_SEPARATOR;
     // Read word/message lists
     foreach ($this->config->readSection('lists') as $identifier => $file) {
         $this->lists[$identifier] = array();
         $f = new File($base . $file);
         try {
             if ($f->open(FILE_MODE_READ)) {
                 while (($line = $f->readLine()) && !$f->eof()) {
                     $this->lists[$identifier][] = $line;
                 }
             }
             $f->close();
         } catch (IOException $e) {
             $e->printStackTrace();
             return FALSE;
         }
     }
     // Read karma recognition phrases
     $f = new File($base . $this->config->readString('karma', 'recognition'));
     try {
         if ($f->open(FILE_MODE_READ)) {
             while (!$f->eof()) {
                 $line = $f->readLine();
                 if (empty($line) || strspn($line, ';#')) {
                     continue;
                 }
                 list($pattern, $channel, $direct) = explode(':', $line);
                 $this->recognition[$pattern] = array((int) $channel, (int) $direct);
             }
         }
         $f->close();
     } catch (IOException $e) {
         $e->printStackTrace();
         return FALSE;
     }
     // If no karma is set and the karma storage exists, load it
     if (0 == sizeof($this->karma)) {
         try {
             $f = new File($base . 'karma.list');
             if ($f->exists()) {
                 $karma = unserialize(FileUtil::getContents($f));
                 if ($karma) {
                     $this->karma = $karma;
                 }
             }
         } catch (IOException $e) {
             // Karma loading failed - log, but ignore...
             $this->cat && $this->cat->error($e);
         }
     }
 }
开发者ID:Gamepay,项目名称:xp-contrib,代码行数:60,代码来源:KrokerdilBotListener.class.php

示例14: loadingNonexistantFile

 public function loadingNonexistantFile()
 {
     $this->assertEquals('Foobar', trim(FileUtil::getContents(new File('res://one/Dummy.txt'))));
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:4,代码来源:ResourceProviderTest.class.php

示例15: fromFile

 /**
  * Create a new checksum from a file object
  *
  * @param   io.File file
  * @param   string key default NULL
  * @return  security.checksum.HMAC_MD5
  */
 public static function fromFile($file, $key = NULL)
 {
     return new HMAC_MD5(HMAC_MD5::hash(FileUtil::getContents($file), $key));
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:11,代码来源:HMAC_MD5.class.php


注:本文中的FileUtil::getContents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。