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


PHP Path::get方法代码示例

本文整理汇总了PHP中Path::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Path::get方法的具体用法?PHP Path::get怎么用?PHP Path::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Path的用法示例。


在下文中一共展示了Path::get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: encode

 public function encode(Path $path)
 {
     $parts = explode(Path::PATH_PART_SEPARATOR, $path->get());
     foreach ($parts as $partIndex => $part) {
         $parts[$partIndex] = rawurlencode($part);
     }
     return new Path(implode(Path::PATH_PART_SEPARATOR, $parts));
 }
开发者ID:webignition,项目名称:url,代码行数:8,代码来源:Encoder.php

示例2: parse

 public static function parse()
 {
     $m = static::getRequestMethod();
     $p = Path::get();
     $maps = static::$map[$m];
     if (!!$maps && is_array($maps) && count($maps) > 0) {
         $matching = '';
         for ($i = count($p) - 1; $i >= 0; $i--) {
             if (!$p[$i]) {
                 array_splice($p, $i, 1);
             }
         }
         $uri = implode('/', $p);
         $min = 1000;
         foreach ($maps as $map) {
             $num = 0;
             $pattern = $map->pattern;
             for ($i = count($pattern) - 1; $i >= 0; $i--) {
                 if (strpos($pattern[$i], ':') === 0) {
                     $pattern[$i] = '(\\w+)';
                     $num++;
                 }
             }
             $sroute = implode('/', $pattern);
             $matcount = 0;
             $min = min(count($pattern), count($p));
             for ($j = 0; $j < $min; $j++) {
                 if ($pattern[$j] == '(\\w+)' || $p[$j] == $pattern[$j]) {
                     $matcount++;
                     continue;
                 }
             }
             if ($matcount == count($pattern)) {
                 if (preg_match_all('#^' . $sroute . '$#', $uri, $matches)) {
                     if ($num < $min) {
                         $min = $num;
                         $matching = (object) ['route' => $map, 'data' => array_slice($matches, 1)];
                     }
                 }
             }
         }
         if (!!$matching && is_object($matching)) {
             $args = [];
             $matches = property_exists($matching, 'data') ? $matching->data : [];
             foreach ($matches as $val) {
                 array_push($args, $val[0]);
             }
             $fn = $matching->route->callback;
             call_user_func_array($fn, $args);
         }
     }
     if ($m == 'HEAD') {
         ob_end_clean();
     }
     return Bella::end();
 }
开发者ID:ndaidong,项目名称:bella.php,代码行数:56,代码来源:Router.php

示例3: testFolderAutoCreationWhenWriting

 /**
  *  a Path instance will try and create the parent folder structure before writing
  *  the contents of the file if the parent folders don't already exist   
  *
  *  @since  9-26-11
  */
 public function testFolderAutoCreationWhenWriting()
 {
     $path_str = (string) $this->getTempPath(md5(microtime(true)), md5(microtime(true)), 'test.txt');
     $set_path_txt = 'this is the string';
     $set_path = new Path($path_str);
     $set_path->set($set_path_txt);
     $get_path = new Path($path_str);
     $get_path_txt = $get_path->get();
     $this->assertSame($set_path_txt, $get_path_txt);
 }
开发者ID:Jaymon,项目名称:Montage,代码行数:16,代码来源:PathTest.php

示例4: setExtends

 /**
  * Fait hériter le fichier de configuration d'un autre fichier.
  * Permet d'incorporer un fichier de configuration par défaut qui sera
  * surchargé par le fichier actuel.
  *
  * @param string $path Chemin vers le fichier de configuration "défaut"
  *
  * @return void
  */
 public function setExtends($path)
 {
     $iniPath = new Path($path);
     $confPath = $iniPath->get();
     if ($confPath !== false) {
         $configBase = parse_ini_file($confPath, true);
     }
     $this->config = $this->arrayMerge($configBase, $this->config);
 }
开发者ID:siwayll,项目名称:deuton,代码行数:18,代码来源:Config.php

示例5: initialize

 public static function initialize($onstart = null, $onfly = null)
 {
     Config::init();
     if (Config::get('active') === 0) {
         return Bella::shutdown();
     }
     $q = Config::get('settings');
     if (is_dir($q->requires_dir)) {
         foreach (glob($q->requires_dir . '*.php') as $file) {
             include_once $file;
         }
     }
     if (is_dir($q->utils_dir)) {
         foreach (glob($q->utils_dir . '*.php') as $file) {
             include_once $file;
         }
     }
     Session::init();
     Path::init();
     Request::init();
     if (isset($onstart) && is_callable($onstart)) {
         $onstart();
     }
     $user = Session::get('user');
     if (!$user) {
         $user = Session::get('manager');
     }
     if (!!$user) {
         Context::set('user', $user);
     }
     $c = Path::get(0);
     if (!$c) {
         Bella::loadCoordinator('index');
     } else {
         $dir = Config::get('settings')->controllers_dir;
         $f = $dir . $c . '.php';
         if (file_exists($f)) {
             Bella::loadCoordinator($c);
         } else {
             if (isset($onfly) && is_callable($onfly)) {
                 return $onfly($c);
             }
         }
     }
 }
开发者ID:ndaidong,项目名称:bella.php,代码行数:45,代码来源:Bella.php


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