本文整理汇总了PHP中SplFileObject::getPathName方法的典型用法代码示例。如果您正苦于以下问题:PHP SplFileObject::getPathName方法的具体用法?PHP SplFileObject::getPathName怎么用?PHP SplFileObject::getPathName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplFileObject
的用法示例。
在下文中一共展示了SplFileObject::getPathName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test
function test($name, $lc, $lp)
{
static $i = 0;
echo "==={$i}===\n";
$i++;
$o = new SplFileInfo($name);
var_dump($o);
$c = clone $o;
var_dump($c);
var_dump($o === $c);
var_dump($o == $c);
var_dump($o->getPathname() == $c->getPathname());
try {
$f = new SplFileObject($name);
var_dump($name);
var_dump($f->getPathName());
$l = substr($f->getPathName(), -1);
var_dump($l != '/' && $l != '\\' && $l == $lc);
var_dump($f->getFileName());
$l = substr($f->getFileName(), -1);
var_dump($l != '/' && $l != '\\' && $l == $lc);
var_dump($f->getPath());
$l = substr($f->getPath(), -1);
var_dump($l != '/' && $l != '\\' && $l == $lp);
} catch (LogicException $e) {
echo "LogicException: " . $e->getMessage() . "\n";
}
try {
$fo = $o->openFile();
var_dump($fo->getPathName(), $fo->getFileName(), $fo->getPath());
} catch (LogicException $e) {
echo "LogicException: " . $e->getMessage() . "\n";
}
}
示例2: __construct
/**
* Construct CSV reader
*
* @param \SplFileObject $file Excel file
* @param int $headerRowNumber Optional number of header row
* @param int $activeSheet Index of active sheet to read from
*/
public function __construct(\SplFileObject $file, $headerRowNumber = null, $activeSheet = null)
{
$reader = \PHPExcel_IOFactory::createReaderForFile($file->getPathName());
$reader->setReadDataOnly(true);
$excel = $reader->load($file->getPathname());
if (null !== $activeSheet) {
$excel->setActiveSheetIndex($activeSheet);
}
$this->worksheet = $excel->getActiveSheet()->toArray();
if (null !== $headerRowNumber) {
$this->setHeaderRowNumber($headerRowNumber);
}
}
示例3: __construct
/**
* @param \SplFileObject $file Excel file
* @param integer $headerRowNumber Optional number of header row
* @param integer $activeSheet Index of active sheet to read from
* @param boolean $readOnly If set to false, the reader take care of the excel formatting (slow)
*/
public function __construct(\SplFileObject $file, $headerRowNumber = null, $activeSheet = null, $readOnly = true)
{
$reader = \PHPExcel_IOFactory::createReaderForFile($file->getPathName());
$reader->setReadDataOnly($readOnly);
/** @var \PHPExcel $excel */
$excel = $reader->load($file->getPathname());
if (null !== $activeSheet) {
$excel->setActiveSheetIndex($activeSheet);
}
$this->worksheet = $excel->getActiveSheet();
$this->maxColumn = $this->worksheet->getHighestColumn();
$this->maxRow = $this->worksheet->getHighestRow();
if (null !== $headerRowNumber) {
$this->setHeaderRowNumber($headerRowNumber);
}
}
示例4: __construct
public function __construct(\SplFileObject $file, $headerRowNumber = null, $activeSheet = null, $readOnly = true, $maxRows = null, $maxCol = null)
{
$this->file = $file;
$this->activeSheet = $activeSheet;
$this->reader = \PHPExcel_IOFactory::createReaderForFile($file->getPathName());
$this->reader->setReadDataOnly($readOnly);
if (!is_null($headerRowNumber)) {
$this->headerRowNumber = $headerRowNumber;
$headerReader = clone $this->reader;
$headerReader->setReadFilter(new ReadFilter($headerRowNumber + 1));
/** @var \PHPExcel $excel */
$excel = $headerReader->load($file->getPathname());
if (null !== $activeSheet) {
$excel->setActiveSheetIndex($activeSheet);
}
$rows = $excel->getActiveSheet()->toArray();
$this->columnHeaders = $rows[$headerRowNumber];
//set max col from header length if not already given
if (is_null($maxCol)) {
$maxCol = \PHPExcel_Cell::stringFromColumnIndex(count($this->columnHeaders) - 1);
}
}
$this->setBoundaries($maxRows, $maxCol);
}
示例5: outputImage
function outputImage($pic)
{
if (!is_object($pic)) {
$pic = new SplFileObject($pic);
}
$picPath = $pic->getPathName();
$picExt = strtolower(substr($picPath, -3));
//jeko moved strtolower only used for preg_match and mime type
// IE gets paths to images, cool kids get base64 image data
if (preg_match('%(jpg|png|gif)%', $picExt)) {
//sm_com preg_match once
if (isIE()) {
return $picPath;
} else {
//sm_com removed if !isIE()
$picData = base64_encode(file_get_contents($picPath));
return "data:image/" . $picExt . ";base64," . $picData;
//sm_com removed switch:
}
} else {
return false;
//sm_com or throw an error (it's not an acceptable image type or not an image)
}
}