当前位置: 首页>>代码示例>>PHP>>正文


PHP SplFileObject::getPathName方法代码示例

本文整理汇总了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";
    }
}
开发者ID:gleamingthecube,项目名称:php,代码行数:34,代码来源:ext_spl_tests_fileobject_003.php

示例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);
     }
 }
开发者ID:ngangchill,项目名称:data-import,代码行数:20,代码来源:ExcelReader.php

示例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);
     }
 }
开发者ID:tegansnyder,项目名称:data-import,代码行数:22,代码来源:ExcelReader.php

示例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);
 }
开发者ID:mathielen,项目名称:import-engine,代码行数:24,代码来源:ExcelReader.php

示例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)
    }
}
开发者ID:jkochis,项目名称:scwape,代码行数:24,代码来源:scwape.php


注:本文中的SplFileObject::getPathName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。