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


PHP SplFileObject::eof方法代码示例

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


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

 /**
  * @param $file
  * @param null $defaultPatternPattern
  */
 public function __construct($file, $defaultPatternPattern = null)
 {
     parent::__construct($defaultPatternPattern);
     $this->file = new \SplFileObject($file, 'r');
     $i = 0;
     while (!$this->file->eof()) {
         $this->file->current();
         $this->file->next();
         $i++;
     }
     $this->lineCount = $i;
     $this->parser = $this->getDefaultParser();
 }
开发者ID:pulse00,项目名称:monolog-parser,代码行数:17,代码来源:LogReader.php

示例3: 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

示例4: __construct

 /**
  * @param        $file
  * @param int    $days
  * @param string $pattern
  */
 public function __construct($file, $days = 1, $pattern = 'default')
 {
     $this->file = new \SplFileObject($file, 'r');
     $i = 0;
     while (!$this->file->eof()) {
         $this->file->current();
         $this->file->next();
         $i++;
     }
     $this->days = $days;
     $this->pattern = $pattern;
     $this->lineCount = $i;
     $this->parser = $this->getDefaultParser($days, $pattern);
 }
开发者ID:hilltool,项目名称:monolog-parser,代码行数:19,代码来源:LogReader.php

示例5: 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

示例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: valid

 /**
  * True if not EOF
  *
  * @return boolean
  */
 public function valid()
 {
     if (null === $this->_file) {
         $this->_openFile();
     }
     return $this->_file && !$this->_file->eof();
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:12,代码来源:FileIteratorAbstract.php

示例8: _getCSVLine

 /**
  * Returns a line form the CSV file and advances the pointer to the next one
  *
  * @param Model $Model
  * @param SplFileObject $handle CSV file handler
  * @return array list of attributes fetched from the CSV file
  */
 protected function _getCSVLine(Model &$Model, SplFileObject $handle)
 {
     if ($handle->eof()) {
         return false;
     }
     return $handle->fgetcsv($this->settings[$Model->alias]['delimiter'], $this->settings[$Model->alias]['enclosure']);
 }
开发者ID:neterslandreau,项目名称:goinggreen,代码行数:14,代码来源:csv_import.php

示例9: 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

示例10: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $values = $form_state->getValues();
     $file = File::load($values['file'][0]);
     // Load File entity.
     $read_file = new \SplFileObject($file->url());
     // Create file handler.
     $lines = 1;
     $in_queue = 0;
     $queue = \Drupal::queue('eventninja');
     // Load queue
     while (!$read_file->eof()) {
         $data = $read_file->fgetcsv(';');
         if ($lines > 1) {
             // skip headers
             $user = user_load_by_mail($data[1]);
             if ($user === false) {
                 // Verify if user with specified email does not exist.
                 $queue->createItem($data);
                 $in_queue++;
             } else {
                 $this->logger('eventninja')->log(RfcLogLevel::NOTICE, 'User {mail} hasn\'t been created.', ['mail' => $data[1]]);
             }
         }
         $lines++;
     }
     if ($lines > 1) {
         drupal_set_message($this->t('@num records was scheduled for import', array('@num' => $in_queue)), 'success');
     } else {
         drupal_set_message($this->t('File contains only headers'), 'error');
     }
 }
开发者ID:slovak-drupal-association,项目名称:dccs,代码行数:35,代码来源:AdminForm.php

示例11: 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

示例12: 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

示例13: __construct

 public function __construct($csvFile)
 {
     $file = new SplFileObject($csvFile);
     while (!$file->eof()) {
         $csv[] = $file->fgetcsv();
     }
     $this->File = $csv;
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:8,代码来源:pan.php

示例14: __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

示例15: prepare

 /**
  * Write the compiled csv to disk and return the file name
  *
  * @param array $sortedHeaders An array of sorted headers
  *
  * @return string The csv filename where the data was written
  */
 public function prepare($cacheFile, $sortedHeaders)
 {
     $csvFile = $cacheFile . '.csv';
     $handle = fopen($csvFile, 'w');
     // Generate a csv version of the multi-row headers to write to disk
     $headerRows = [[], []];
     foreach ($sortedHeaders as $idx => $header) {
         if (!is_array($header)) {
             $headerRows[0][] = $header;
             $headerRows[1][] = '';
         } else {
             foreach ($header as $headerName => $subHeaders) {
                 $headerRows[0][] = $headerName;
                 $headerRows[1] = array_merge($headerRows[1], $subHeaders);
                 if (count($subHeaders) > 1) {
                     /**
                      * We need to insert empty cells for the first row of headers to account for the second row
                      * this acts as a faux horizontal cell merge in a csv file
                      * | Header 1 | <---- 2 extra cells ----> |
                      * | Sub 1    | Subheader 2 | Subheader 3 |
                      */
                     $headerRows[0] = array_merge($headerRows[0], array_fill(0, count($subHeaders) - 1, ''));
                 }
             }
         }
     }
     fputcsv($handle, $headerRows[0]);
     fputcsv($handle, $headerRows[1]);
     // TODO: Track memory usage
     $file = new \SplFileObject($cacheFile);
     while (!$file->eof()) {
         $csvRow = [];
         $row = json_decode($file->current(), true);
         if (!is_array($row)) {
             // Invalid json data -- don't process this row
             continue;
         }
         foreach ($sortedHeaders as $idx => $header) {
             if (!is_array($header)) {
                 $csvRow[] = isset($row[$header]) ? $row[$header] : '';
             } else {
                 // Multi-row header, so we need to set all values
                 $nestedHeaderName = array_keys($header)[0];
                 $nestedHeaders = $header[$nestedHeaderName];
                 foreach ($nestedHeaders as $nestedHeader) {
                     $csvRow[] = isset($row[$nestedHeaderName][$nestedHeader]) ? $row[$nestedHeaderName][$nestedHeader] : '';
                 }
             }
         }
         fputcsv($handle, $csvRow);
         $file->next();
     }
     $file = null;
     // Get rid of the file handle that SplFileObject has on cache file
     unlink($cacheFile);
     fclose($handle);
     return $csvFile;
 }
开发者ID:rushi,项目名称:XolaReportWriterBundle,代码行数:65,代码来源:CSVWriter.php


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