本文整理匯總了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']);
}
示例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());
}
}
示例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;
}