當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SplFileObject::getPath方法代碼示例

本文整理匯總了PHP中SplFileObject::getPath方法的典型用法代碼示例。如果您正苦於以下問題:PHP SplFileObject::getPath方法的具體用法?PHP SplFileObject::getPath怎麽用?PHP SplFileObject::getPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SplFileObject的用法示例。


在下文中一共展示了SplFileObject::getPath方法的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

 /**
  * Constructor
  *
  * @param \SplFileObject $post Post source file
  */
 public function __construct(\SplFileObject $post)
 {
     $this->source = $post;
     if (!preg_match('/[\\d]{4}\\/[\\d]{2}\\/(.+)$/', $post->getPathname())) {
         throw new \Exception(sprintf('%s is not a valid post', $post->getPathname()));
     }
     $paths = explode(DIRECTORY_SEPARATOR, $post->getPath());
     $this->month = $paths[count($paths) - 1];
     $this->year = $paths[count($paths) - 2];
     $this->slug = $post->getBasename('.' . $post->getExtension());
 }
開發者ID:jeremyharris,項目名稱:build,代碼行數:16,代碼來源:Post.php

示例3: getFilename

 /**
  * @return string
  */
 public function getFilename()
 {
     return $this->movieFile->getPath() . DIRECTORY_SEPARATOR . $this->movieFile->getBasename();
 }
開發者ID:mihaeu,項目名稱:sub-collector,代碼行數:7,代碼來源:File.php

示例4: SplFileObject

<?php

set_include_path('tests');
chdir(dirname(dirname(__FILE__)));
// ext/spl
$fo = new SplFileObject('fileobject_004.phpt', 'r', true);
var_dump($fo->getPath());
var_dump($fo->getFilename());
var_dump($fo->getRealPath());
?>
==DONE==
開發者ID:badlamer,項目名稱:hhvm,代碼行數:11,代碼來源:fileobject_004.php

示例5: compileLess

 /**
  * Compiles all required resources for the passed shop and template.
  * The function compiles all theme and plugin less files and
  * compresses the theme and plugin javascript and css files
  * into one file.
  *
  * @param $timestamp
  * @param Shop\Template $template
  * @param Shop\Shop $shop
  * @throws \Exception
  */
 public function compileLess($timestamp, Shop\Template $template, Shop\Shop $shop)
 {
     if ($shop->getMain()) {
         $shop = $shop->getMain();
     }
     $file = $this->pathResolver->getCssFilePath($shop, $timestamp);
     $file = new \SplFileObject($file, "a");
     if (!$file->flock(LOCK_EX)) {
         return;
     }
     $file->ftruncate(0);
     $this->compiler->setConfiguration($this->getCompilerConfiguration($shop));
     $config = $this->getConfig($template, $shop);
     $this->compiler->setVariables($config);
     $definitions = $this->collectLessDefinitions($template, $shop);
     foreach ($definitions as $definition) {
         $this->compileLessDefinition($shop, $definition);
     }
     $css = $this->compiler->get();
     $this->compiler->reset();
     $success = $file->fwrite($css);
     if ($success === null) {
         throw new \RuntimeException("Could not write to " . $file->getPath());
     }
     $file->flock(LOCK_UN);
     // release the lock
 }
開發者ID:GerDner,項目名稱:luck-docker,代碼行數:38,代碼來源:Compiler.php


注:本文中的SplFileObject::getPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。