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


PHP SplFileObject::fgetc方法代码示例

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


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

示例1: readBytes

 private function readBytes($length)
 {
     $stream = null;
     for ($cc = 0; $cc < $length; $cc++) {
         if ($this->file->eof()) {
             return null;
         }
         $stream .= $this->file->fgetc();
     }
     return $stream;
 }
开发者ID:fcm,项目名称:GovernorFramework,代码行数:11,代码来源:FilesystemEventMessageReader.php

示例2: _skipBom

 /**
  * Skip any BOM in the file
  */
 private function _skipBom()
 {
     $bom = $this->_file->fgetc() . $this->_file->fgetc() . $this->_file->fgetc();
     // If there is no bom, then remove bom will return a 3 character string.
     // In that case the file position must be reset to the start of the file
     if (\MUtil_Encoding::removeBOM($bom)) {
         $this->_file->rewind();
     }
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:12,代码来源:FileIteratorAbstract.php

示例3: goBeforeCharacter

 /**
  * {@inheritdoc}
  */
 public function goBeforeCharacter(\SplFileObject $file, $characterNumber)
 {
     $file->rewind();
     if ($characterNumber < 0 || $characterNumber > $file->getSize()) {
         throw new OutOfBoundsException();
     }
     for ($i = 0; $i <= $characterNumber - 1; $i++) {
         $file->fgetc();
     }
     return $file;
 }
开发者ID:Babacooll,项目名称:TextFile,代码行数:14,代码来源:SimpleWalker.php

示例4: test

function test($name)
{
    echo "==={$name}===\n";
    $o = new SplFileObject(dirname(__FILE__) . '/' . $name);
    var_dump($o->key());
    while (($c = $o->fgetc()) !== false) {
        var_dump($o->key(), $c, $o->eof());
    }
    echo "===EOF?===\n";
    var_dump($o->eof());
    var_dump($o->key());
    var_dump($o->eof());
}
开发者ID:gleamingthecube,项目名称:php,代码行数:13,代码来源:ext_spl_tests_fileobject_002.php

示例5: readLines

 /**
  * @param \SplFileObject $file
  *
  * @return \Generator
  */
 private function readLines($file)
 {
     $pos = -1;
     $currentLine = '';
     while (-1 !== $file->fseek($pos, SEEK_END)) {
         $char = $file->fgetc();
         if (PHP_EOL === $char) {
             (yield $currentLine);
             $currentLine = '';
         } else {
             $currentLine = $char . $currentLine;
         }
         $pos--;
     }
     if (strlen($currentLine) > 0) {
         (yield $currentLine);
     }
 }
开发者ID:warlock39,项目名称:webserverlog,代码行数:23,代码来源:Reader.php

示例6: readLong

 /**
  * @param \SplFileObject $file
  * @return int
  */
 private function readLong($file)
 {
     $stream = null;
     for ($cc = 0; $cc < 4; $cc++) {
         if ($file->eof()) {
             return null;
         }
         $stream .= $file->fgetc();
     }
     $data = unpack("Nskip", $stream);
     return $data['skip'];
 }
开发者ID:fcm,项目名称:GovernorFramework,代码行数:16,代码来源:FilesystemSnapshotEventReader.php

示例7: peek

 /**
  * Get the next character from the input stream, without gettng it.
  *
  * @return  string      The next character from the specified input stream, without advancing the position
  *                      in the underlying file.
  * @see     $in
  * @see     get()
  */
 function peek()
 {
     if ($this->isString) {
         if ($this->inPos < $this->inLength) {
             $c = $this->in[$this->inPos];
         } else {
             return EOF;
         }
     } else {
         // Get next input character
         $c = $this->in->fgetc();
         // Regress position in file
         $this->in->fseek(-1, SEEK_CUR);
         // Return character obtained
     }
     return $c;
 }
开发者ID:pylasrenu,项目名称:Utils,代码行数:25,代码来源:jsmin.php

示例8: getNextCharacterContent

 /**
  * {@inheritdoc}
  */
 public function getNextCharacterContent(\SplFileObject $file)
 {
     $originalPosition = $file->ftell();
     $character = $file->fgetc();
     $this->walker->goBeforeCharacter($file, $originalPosition);
     return $character;
 }
开发者ID:Babacooll,项目名称:TextFile,代码行数:10,代码来源:SimpleReader.php

示例9: getCharacter

 /**
  * Gets a character from the given resource.
  *
  * @throws \YapepBase\Exception\File\Exception   In case the object does not have an opened file.
  *
  * @return string|bool   The character, or FALSE if the pointer is at the end of the resource.
  */
 public function getCharacter()
 {
     $this->checkIfFileOpened();
     return $this->splFile->fgetc();
 }
开发者ID:szeber,项目名称:yapep_base,代码行数:12,代码来源:ResourceHandlerPhp.php


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