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


PHP SplFileObject::fgets方法代码示例

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


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

示例1: current

 public function current()
 {
     $type = 'unkown';
     $isCovered = false;
     if (isset($this->lines[$this->position])) {
         $type = $this->lines[$this->position]['type'];
         $isCovered = $this->lines[$this->position]['isCovered'];
     }
     return array('type' => $type, 'isCovered' => $isCovered, 'content' => $this->file->fgets());
 }
开发者ID:fezfez,项目名称:coverage-clover-viewer,代码行数:10,代码来源:LineIterator.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (parent::execute($input, $output)) {
         $this->loadOCConfig();
         $properties = array('string $id', 'string $template', 'array $children', 'array $data', 'string $output');
         // TODO: get all library classes as well, maybe extract from registry somehow...
         $searchLine = "abstract class Controller {";
         $pathToController = "engine/controller.php";
         $catalogModels = $this->getModels(\DIR_APPLICATION);
         $adminModels = $this->getModels(str_ireplace("catalog/", "admin/", \DIR_APPLICATION));
         $textToInsert = array_unique(array_merge($properties, $catalogModels, $adminModels));
         //get line number where start Controller description
         $fp = fopen(\DIR_SYSTEM . $pathToController, 'r');
         $lineNumber = $this->getLineOfFile($fp, $searchLine);
         fclose($fp);
         //regenerate Controller text with properties
         $file = new \SplFileObject(\DIR_SYSTEM . $pathToController);
         $file->seek($lineNumber);
         $tempFile = sprintf("<?php %s \t/**%s", PHP_EOL, PHP_EOL);
         foreach ($textToInsert as $val) {
             $tempFile .= sprintf("\t* @property %s%s", $val, PHP_EOL);
         }
         $tempFile .= sprintf("\t**/%s%s%s", PHP_EOL, $searchLine, PHP_EOL);
         while (!$file->eof()) {
             $tempFile .= $file->fgets();
         }
         //write Controller
         $fp = fopen(\DIR_SYSTEM . $pathToController, 'w');
         fwrite($fp, $tempFile);
         fclose($fp);
     }
 }
开发者ID:beyondit,项目名称:ocok,代码行数:32,代码来源:PHPDocCommand.php

示例3: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $filename = $input->getArgument('filename');
     if (!file_exists($filename)) {
         throw new \Symfony\Component\HttpKernel\Exception\BadRequestHttpException("Le fichier {$filename} n'existe pas.");
     }
     // Indicateurs
     $i = 0;
     // Nombre de mots-clés importés
     $em = $this->getContainer()->get('doctrine')->getManager();
     $categorieRepository = $em->getRepository('ComptesBundle:Categorie');
     $file = new \SplFileObject($filename);
     while (!$file->eof()) {
         $line = $file->fgets();
         list($word, $categorieID) = explode(':', $line);
         $word = trim($word);
         $categorieID = (int) $categorieID;
         $categorie = $categorieRepository->find($categorieID);
         if ($categorie === null) {
             throw new \Symfony\Component\HttpKernel\Exception\NotFoundHttpException("La catégorie n°{$categorieID} est inconnue.");
         }
         $keyword = new Keyword();
         $keyword->setWord($word);
         $keyword->setCategorie($categorie);
         // Indicateurs
         $i++;
         // Enregistrement
         $em->persist($keyword);
     }
     // Persistance des données
     $em->flush();
     // Indicateurs
     $output->writeln("<info>{$i} mots-clés importés</info>");
 }
开发者ID:NCapiaumont,项目名称:comptes,代码行数:37,代码来源:KeywordsImportCommand.php

示例4: fgets

 function fgets()
 {
     if (!$this->valid()) {
         return false;
     }
     return parent::fgets();
 }
开发者ID:jstacoder,项目名称:brushfire,代码行数:7,代码来源:FileObject.php

示例5: actionIndex

 public function actionIndex($path = null, $fix = null)
 {
     if ($path === null) {
         $path = YII_PATH;
     }
     echo "Checking {$path} for files with BOM.\n";
     $checkFiles = CFileHelper::findFiles($path, array('exclude' => array('.gitignore')));
     $detected = false;
     foreach ($checkFiles as $file) {
         $fileObj = new SplFileObject($file);
         if (!$fileObj->eof() && false !== strpos($fileObj->fgets(), self::BOM)) {
             if (!$detected) {
                 echo "Detected BOM in:\n";
                 $detected = true;
             }
             echo $file . "\n";
             if ($fix) {
                 file_put_contents($file, substr(file_get_contents($file), 3));
             }
         }
     }
     if (!$detected) {
         echo "No files with BOM were detected.\n";
     } else {
         if ($fix) {
             echo "All files were fixed.\n";
         }
     }
 }
开发者ID:super-d2,项目名称:codeigniter_demo,代码行数:29,代码来源:CheckBomCommand.php

示例6: upload_hathdl

function upload_hathdl()
{
    $file = new SplFileObject($_FILES['ehgfile']['tmp_name']);
    $gid = -1;
    $page = -1;
    $title = null;
    $tags = null;
    while (!$file->eof()) {
        $line = $file->fgets();
        $line = trim($line);
        $token = explode(' ', $line);
        if (strcmp($token[0], 'GID') == 0) {
            $gid = intval($token[1]);
        } else {
            if (strcmp($token[0], 'FILES') == 0) {
                $page = intval($token[1]);
            } else {
                if (strcmp($token[0], 'TITLE') == 0) {
                    $title = trim(preg_replace('TITLE', '', $line));
                } else {
                    if (strcmp($token[0], 'Tags:') == 0) {
                        $tags = trim(preg_replace('Tags:', '', $line));
                    }
                }
            }
        }
    }
    shell_exec('cp ' . $_FILES['ehgfile']['tmp_name'] . ' hentaiathome/hathdl/');
    $info['gid'] = $gid;
    $info['page'] = $page;
    $info['title'] = $title;
    $info['tags'] = $tags;
    return $info;
}
开发者ID:subsevenx2001,项目名称:HathHelper,代码行数:34,代码来源:lib.php

示例7: __construct

 public function __construct($filepath)
 {
     $file = new \SplFileObject($filepath);
     $this->path = $file->getFilename();
     while (!$file->eof()) {
         $this->content .= $file->fgets();
     }
 }
开发者ID:kaiwa,项目名称:clsi-client,代码行数:8,代码来源:TextFileResource.php

示例8: getLine

 /**
  * Gets a line from the given resource.
  *
  * @link http://php.net/manual/en/function.fgets.php
  *
  * @param int $length   If set the reading will end when the given length reached.
  *
  * @throws \YapepBase\Exception\File\Exception   In case the object does not have an opened file.
  *
  * @return string|bool   The line. Or FALSE if the pointer is at the end of the resource, or on error.
  */
 public function getLine($length = null)
 {
     $this->checkIfFileOpened();
     if ($this->checkIfPointerIsAtTheEnd()) {
         return false;
     }
     return $this->splFile->fgets();
 }
开发者ID:szeber,项目名称:yapep_base,代码行数:19,代码来源:ResourceHandlerPhp.php

示例9: loadJson

 /**
  * Load file content and decode the json
  */
 protected function loadJson()
 {
     $lines = '';
     while (!$this->file->eof()) {
         $lines .= $this->file->fgets();
     }
     $this->json = json_decode($lines);
 }
开发者ID:tiagobutzke,项目名称:json2dto,代码行数:11,代码来源:Loader.php

示例10: loadJsonFromFile

 /**
  * Loads the config from a json file
  *
  * @param $configFile
  *
  * @throws ConfigException
  */
 private function loadJsonFromFile($configFile)
 {
     $file = new \SplFileObject($configFile, 'r+');
     $json = $file->fgets();
     $this->config = json_decode($json);
     if (json_last_error() != JSON_ERROR_NONE) {
         throw new ConfigException("Problem reading json");
     }
 }
开发者ID:stedop,项目名称:playground-framework,代码行数:16,代码来源:Config.php

示例11: freeUsedRequestCount

 /**
  * Free the used slots
  *
  * @param $sliced_report_definitions_count
  */
 private function freeUsedRequestCount($sliced_report_definitions_count)
 {
     $this->file_counter->flock(LOCK_EX);
     $this->file_counter->rewind();
     $used_request_count = (int) $this->file_counter->fgets();
     $new_used_request_count = $used_request_count - $sliced_report_definitions_count;
     $this->file_counter->ftruncate(0);
     $this->file_counter->fwrite($new_used_request_count);
     $this->file_counter->flock(LOCK_UN);
 }
开发者ID:ebussola,项目名称:adwords-reports,代码行数:15,代码来源:Reports.php

示例12: SendNewOrderMessage

 public static function SendNewOrderMessage($account, $orderId, $PriceSum)
 {
     $file = new SplFileObject(__ROOT__ . '/application/EmailService/EmailTemplates/order.txt');
     $message = '';
     while (!$file->eof()) {
         $message = $message . $file->fgets();
     }
     $message = str_replace('@AccountName', $account->account_name, $message);
     $message = str_replace('@OrderId', $orderId, $message);
     $message = str_replace('@Price', $PriceSum, $message);
     mail($account->email, 'Регистрация', $message, 'Content-type:text/html;');
 }
开发者ID:krasaler,项目名称:FamilyStore,代码行数:12,代码来源:EmailService.php

示例13: _clearDirectory

 /**
  * Clears a directory of cached files with the correct header.
  *
  * @return void
  */
 protected function _clearDirectory($path)
 {
     $dir = new DirectoryIterator($path);
     foreach ($dir as $file) {
         $fileInfo = new SplFileObject($file->getPathname());
         $line = $fileInfo->fgets();
         if (preg_match('#^/\\* asset_compress \\d+ \\*/$#', $line)) {
             $this->out('Deleting ' . $fileInfo->getPathname());
             unlink($fileInfo->getPathname());
         }
     }
 }
开发者ID:sdoney,项目名称:asset_compress,代码行数:17,代码来源:asset_compress.php

示例14: importFile

 /**
  * Imports given JSON file
  * @param string $filePath Path to a JSON file with data to import
  * @return array Array with import output - metadata, status, warnings and errors
  */
 public function importFile($filePath)
 {
     $this->tmpFile = new SplFileObject($filePath, "r");
     $curState = new JSONImportStateStart(array('meta' => array(), 'result' => array(), 'user_id' => $this->params['user_id']));
     $result = array('success' => false);
     $stepResult = false;
     while (!$this->tmpFile->eof()) {
         $curLine = trim($this->tmpFile->fgets());
         $stepResult = $curState->processLine($curLine);
         // Returns next state for processing
         if (!is_array($stepResult)) {
             $curState = $stepResult;
             // Returned array with results
         } else {
             $result = $stepResult;
             $result['success'] = true;
             break;
         }
     }
     return $result;
 }
开发者ID:iweave,项目名称:unmark,代码行数:26,代码来源:JSONImport.php

示例15: getContent

 /**
  *
  * because \SplFileObject::fread() is not available before 5.5.11 anyway
  * 
  * returns the full content of a file, rewinds pointer in the beginning and leaves it at the end
  * but dont rely on this pointer behaviour
  * 
  * @param \SplFileObject $fileObject
  *
  * @return \SplString|string
  */
 public static function getContent(\SplFileObject $fileObject)
 {
     if (class_exists('SplString')) {
         $result = new \SplString();
     } else {
         $result = '';
     }
     $fileObject->rewind();
     while (!$fileObject->eof()) {
         $result .= $fileObject->fgets();
     }
     return $result;
 }
开发者ID:cotya,项目名称:composer-test-framework,代码行数:24,代码来源:FileObject.php


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