當前位置: 首頁>>代碼示例>>PHP>>正文


PHP File::openFile方法代碼示例

本文整理匯總了PHP中Symfony\Component\HttpFoundation\File\File::openFile方法的典型用法代碼示例。如果您正苦於以下問題:PHP File::openFile方法的具體用法?PHP File::openFile怎麽用?PHP File::openFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\HttpFoundation\File\File的用法示例。


在下文中一共展示了File::openFile方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * Class constructor.
  *
  * @param \Symfony\Component\HttpFoundation\File\File $info
  * @param string                                      $mime_type
  * @param string                                      $extension
  */
 public function __construct(SymfonyFile $info, $mime_type = null, $extension = null)
 {
     // Symfony will help us guess things about this file
     $this->info = $info;
     // Sometimes we want to specify the MIME type ourselves
     $this->mime_type = $mime_type;
     // Sometimes we want to specify the extension ourselves
     $this->extension = $extension;
     // Get the SplFileObject from the SplFileInfo
     $this->object = $this->info->openFile();
     // Kill any temporary files created in the lifetime of this object
     register_shutdown_function([$this, 'unlink']);
 }
開發者ID:fuzz-productions,項目名稱:image-resizer,代碼行數:20,代碼來源:File.php

示例2: __construct

 /**
  * Constructor
  *
  * @param string $streetNames Path of the file containing the street names
  */
 public function __construct($streetNames)
 {
     $file = new File($streetNames);
     $splFileObject = $file->openFile('r');
     while (!$splFileObject->eof()) {
         $this->streetNames[] = trim($splFileObject->fgets());
     }
 }
開發者ID:r1pp3rj4ck,項目名稱:r1pp3rj4ckLipsumBundle,代碼行數:13,代碼來源:AddressGenerator.php

示例3: populateNames

 /**
  * Populate names from file to an array
  *
  * @param string $filename File name containing the names
  *
  * @return array
  * @author r1pp3rj4ck <attila.bukor@gmail.com>
  */
 private function populateNames($filename)
 {
     $names = array();
     $file = new File($filename);
     $splFileObject = $file->openFile('r');
     while (!$splFileObject->eof()) {
         $names[] = trim($splFileObject->fgets());
     }
     return $names;
 }
開發者ID:r1pp3rj4ck,項目名稱:r1pp3rj4ckLipsumBundle,代碼行數:18,代碼來源:ProfileGenerator.php


注:本文中的Symfony\Component\HttpFoundation\File\File::openFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。