本文整理汇总了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;
}