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


PHP path::relativeToAnother方法代码示例

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


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

示例1: testRelativeToAnother

 public function testRelativeToAnother()
 {
     $this->assertEquals('', path::relativeToAnother('', ''));
     $this->assertEquals('', path::relativeToAnother('alphA', 'alphA'));
     $this->assertEquals('', path::relativeToAnother('alphA/bEta', 'alphA/bEta'));
     $this->assertEquals(false, path::relativeToAnother('alphA/bEta', 'alphA/betA'));
     $this->assertEquals('betA', path::relativeToAnother('alphA', 'alphA/betA'));
     $this->assertEquals('betA', path::relativeToAnother('alphA/', 'alphA/betA'));
     $this->assertEquals('betA/gammA', path::relativeToAnother('alphA/', 'alphA/betA/gammA'));
     $this->assertEquals(false, path::relativeToAnother('/alphA/', 'alphA/betA/gammA'));
     $this->assertEquals('betA/gammA', path::relativeToAnother('/alphA/', '/alphA/betA/gammA'));
 }
开发者ID:cepharum,项目名称:txf,代码行数:12,代码来源:pathTest.php

示例2: __construct

 public function __construct()
 {
     // include some initial assertions on current context providing minimum
     // set of expected information
     assert('$_SERVER["HTTP_HOST"]');
     assert('$_SERVER["DOCUMENT_ROOT"]');
     assert('$_SERVER["SCRIPT_FILENAME"]');
     /*
      * PHASE 1: Detect basic pathnames and URL components
      */
     $this->frameworkPathname = dirname(dirname(__FILE__));
     $this->installationPathname = dirname($this->frameworkPathname);
     $this->isHTTPS = $_SERVER['HTTPS'] != false || $_SERVER['HTTP_X_HTTPS'] != false;
     // analyse special case of working behind reverse proxy
     if (array_key_exists('HTTP_X_ORIGINAL_URL', $_SERVER)) {
         $url = parse_url($_SERVER['HTTP_X_ORIGINAL_URL']);
         $this->hostname = $url['host'];
         $proxyPrefix = $url['path'];
     } else {
         $proxyPrefix = false;
     }
     if (trim($this->hostname) === '') {
         $this->hostname = $_SERVER['HTTP_HOST'];
     }
     /*
      * PHASE 2: Validate and detect current application
      */
     // validate location of processing script ...
     // ... must be inside document root
     if (path::isInWebfolder($_SERVER['SCRIPT_FILENAME']) === false) {
         throw new \InvalidArgumentException('script is not part of webspace');
     }
     // ... must be inside installation folder of TXF
     $this->scriptPathname = path::relativeToAnother($this->installationPathname, realpath($_SERVER['SCRIPT_FILENAME']));
     if ($this->scriptPathname === false) {
         throw new \InvalidArgumentException('script is not part of TXF installation');
     }
     // derive URL's path prefix to select folder containing TXF installation
     $this->prefixPathname = path::relativeToAnother(realpath(static::getDocumentRoot()), $this->installationPathname);
     if ($this->prefixPathname === false) {
         // installation's folder might be linked into document root using symlink
         // --> comparing pathname of current script with document root will fail then
         //     --> try alternative method to find prefix pathname
         $this->prefixPathname = path::relativeToAnother(static::getDocumentRoot(), dirname($_SERVER['SCRIPT_FILENAME']));
     }
     // running behind reverse proxy?
     if ($proxyPrefix) {
         // detect prefix used to control that reverse proxy
         $request = implode('/', $this->getRequestedScriptUri($dummy));
         $split = strpos($proxyPrefix, $request);
         if ($split >= 0) {
             // extract prefix required by reverse proxy
             $proxyPrefix = substr($proxyPrefix, 0, $split);
             // prepend extracted prefix of reverse proxy to previously
             // detected prefix used to address installation of TXF locally
             $this->prefixPathname = path::glue($proxyPrefix, $this->prefixPathname);
         }
     }
     // cache some derivable names
     list($this->applicationPathname, $this->applicationScriptPathname) = path::stripCommonPrefix($this->scriptPathname, $this->prefixPathname, null);
     // compile base URL of current installation
     $this->url = path::glue(($this->isHTTPS ? 'https://' : 'http://') . $this->hostname, $this->prefixPathname);
     // detect current application
     $this->application = application::current($this);
 }
开发者ID:cepharum,项目名称:txf,代码行数:65,代码来源:context.php


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