本文整理汇总了PHP中SplFileObject::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP SplFileObject::__construct方法的具体用法?PHP SplFileObject::__construct怎么用?PHP SplFileObject::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplFileObject
的用法示例。
在下文中一共展示了SplFileObject::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($filename, $context)
{
// Call parent
parent::__construct($filename);
// Pass image context
$this->setContext($context);
}
示例2: __construct
public function __construct($filename)
{
try {
parent::__construct($filename);
} catch (\RuntimeException $e) {
throw new FileNotFoundException($filename);
}
}
示例3: __construct
public function __construct($filename, $mode = 'r', $use_include_path = false, $context = null)
{
parent::__construct($filename);
$this->setFlags(SplFileObject::READ_CSV);
$this->setCsvControl($this->_delimiter, $this->_enclosure);
$this->rewind();
$this->_map = parent::current();
}
示例4: __construct
/**
* ( excerpt from http://php.net/manual/en/spltempfileobject.construct.php
* )
*
* Construct a new temporary file object.
*
* @maxMemory mixed The maximum amount of memory (in bytes, default is 2
* MB) for the temporary file to use. If the temporary
* file exceeds this size, it will be moved to a file
* in the system's temp directory.
*
* If max_memory is negative, only memory will be
* used. If max_memory is zero, no memory will be used.
*
* @return mixed No value is returned.
*/
public function __construct($maxMemory = null)
{
if ($maxMemory === null) {
parent::__construct('php://temp', 'r+');
} else {
parent::__construct("php://temp/maxmemory:{$maxMemory}", 'r+');
}
}
示例5: __construct
/**
* @param string $filename
* @param int $columnTitlesIndex
* @param string $open_mode
* @param bool $use_include_path
* @param null $context
*/
public function __construct($filename, $columnTitlesIndex = -1, $open_mode = 'r', $use_include_path = false, $context = null)
{
$this->columnTitlesIndex = $columnTitlesIndex;
if (is_null($context)) {
parent::__construct($filename, $open_mode, $use_include_path);
} else {
parent::__construct($filename, $open_mode, $use_include_path, $context);
}
}
示例6: tempnam
/**
* @constructor
*
* @param {?string} $defaultContentType Default mimetype of the uploading file,
* when finfo failed in guessing one.
*/
function __construct($defaultContentType = 'application/octet-stream')
{
if ($defaultContentType) {
$this->defaultContentType = $defaultContentType;
}
$file = tempnam(sys_get_temp_dir(), 'tmp.');
stream_copy_to_stream(fopen('php://input', 'r'), fopen($file, 'r'));
parent::__construct($file);
}
示例7: __construct
public function __construct($filename, $openMode = 'r', $useIncludePath = 'false', $context = null)
{
if (isset($context)) {
parent::__construct($filename, $openMode, $useIncludePath, $context);
} else {
parent::__construct($filename, $openMode, $useIncludePath);
}
$this->setFileClass('Stalxed\\FileSystem\\FileObject');
$this->setInfoClass('Stalxed\\FileSystem\\FileInfo');
}
示例8: __construct
/**
* CsvFileReader constructor.
*
* @param string|File $filePath CSVファイルのFileインスタンスかファイルパス
*/
public function __construct($filePath)
{
if (is_a($filePath, 'File')) {
$filePath = $filePath->path;
}
$tmp = NetCommonsFile::getTemporaryFileConvertSjisWin2Utf8($filePath);
$path = $tmp->path;
parent::__construct($path);
$this->setFlags(SplFileObject::READ_CSV);
}
示例9: catch
/**
* Creates an extended SplFileObject from the given filename, which
* prevents against null byte injections and unprintable characters.
*
* @param string $path the path to the file (path && file name)
*
* @return does not return a value.
*/
function __construct($path)
{
try {
@parent::__construct($path);
} catch (Exception $e) {
throw new EnterpriseSecurityException('Failed to open stream', 'Failed to open stream ' . $e->getMessage());
}
$this->_doDirCheck($path);
$this->_doFileCheck($path);
$this->_doExtraCheck($path);
}
示例10:
/**
* @constructor
*
* @param {array|string} Either path to target file, or an array in $_FILES format.
*/
function __construct($file, $open_mode = 'r', $use_include_path = false, $resource = null)
{
if (is_array($file)) {
// POST filename
if (trim(@$file['name'])) {
$this->filename = $file['name'];
}
$filename = $file['tmp_name'];
} else {
$filename = (string) $file;
}
parent::__construct($filename, $open_mode, $use_include_path, $resource);
}
示例11: __construct
public function __construct($path, $mime_type = null, $width = null, $height = null)
{
if (!is_file($path)) {
throw new \Exception('File not found : ' . $path);
}
parent::__construct($path);
$this->findMimeType($path);
$this->mimeType = $mime_type ?: $this->findMimeType($path);
if (in_array($this->mimeType, $this->resizableMimeType)) {
$this->width = $width;
$this->height = $height;
}
}
示例12: __construct
/**
* Konstruktor
* @param string $path Pfad zu der Datei
* @param int $line_start_position
* @param null $line_end_position
* @throws FileException
*/
public function __construct($path, $line_start_position = 0, $line_end_position = null)
{
if (!is_string($path)) {
throw new \InvalidArgumentException('File: $path not a string');
}
$this->path = $path;
try {
parent::__construct($path);
} catch (Exception $e) {
throw new FileNotReadableException($message = 'File can not read', $code = 100, $previous = $e);
}
$this->line_start_position = $line_start_position;
$this->line_end_position = $line_end_position;
}
示例13: __construct
/**
* See the documentation for SplFileObject
*
* @return this
**/
public function __construct($filename, $openMode, $useIncludePath, $context)
{
// construct per the parent constructor
if (empty($context)) {
// stinking annoying PHP gotchas
parent::__construct($filename, $openMode, $useIncludePath);
} else {
parent::__construct($filename, $openMode, $useIncludePath, $context);
}
// set default CSV options
$this->setFlags(SplFileObject::READ_CSV);
// return
return $this;
}
示例14: __construct
/**
* Construct a new file object and set defaults.
*
* @param string $file
* @param string $mode
* @param bool $include
* @param stream $context
* @return Interspire_File
*/
public function __construct($file, $mode = 'r', $include = false, $context = null)
{
if ($context) {
parent::__construct($file, $mode, $include, $context);
}
else {
parent::__construct($file, $mode, $include);
}
if (method_exists('SplFileObject', 'getRealPath')) {
// getRealPath is PHP >= 5.2.2
$this->realpath = parent::getRealPath();
} else {
$this->realpath = realpath($file);
}
}
示例15: __construct
public function __construct($filename = null, $open_mode = "a")
{
$filename = $filename ?: APP_PATH . "/log" . DS . \Yaf\ENVIRON . ".log";
parent::__construct($filename, $open_mode);
}