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


PHP Net_URL2::normalize方法代码示例

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


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

示例1: __set

 /**
  * Property setter interceptor to handle "host" special case.
  *
  * @param string $property The property to retrieve
  * @param mixed  $value    The property value
  * 
  * @return void
  */
 public function __set($property, $value)
 {
     switch ($property) {
         case 'uri':
             if ($value == null) {
                 return;
             }
             $this->_uri = new Net_URL2($value);
             $this->_uri->normalize();
             // if we have a proxy set, URI must be absolute
             if ($this->_proxy !== null && !$this->_uri->isAbsolute()) {
                 throw new HTTP_Request2_Exception('URI must be absolute when using a proxy');
             }
             // if we use HTTP/1.0, URI must also be absolute
             if ($this->httpVersion == self::HTTP_VERSION_1_0 && !$this->_uri->isAbsolute()) {
                 throw new HTTP_Request2_Exception('URI must be absolute when using ' . self::HTTP_VERSION_1_0);
             }
             break;
         case 'proxy':
             // if we have a proxy set, URI must be absolute
             if ($this->_uri !== null && !$this->_uri->isAbsolute()) {
                 throw new HTTP_Request2_Exception('URI must be absolute when using a proxy');
             }
             $this->_proxy = $value;
             break;
         case 'connection':
             if (!$value instanceof HTTP_Connection) {
                 throw new HTTP_Request2_Exception('connection must be an instance of HTTP_Connection');
             }
             $this->_connection = $value;
             break;
         case 'path':
         case 'host':
         case 'port':
             throw new HTTP_Request2_Exception('"' . $property . '" is a read-only property');
     }
 }
开发者ID:baijnath-sag,项目名称:izi-sandbox,代码行数:45,代码来源:Request2.php

示例2: test20157

 /**
  * This is a regression test to test that setting "0" as path
  * does not break normalize().
  *
  * It was reported as Bug #20157 on 2013-12-27 23:42 UTC that
  * normalize() with "0" as path would not work.
  *
  * @covers Net_URL2::normalize
  * @return void
  */
 public function test20157()
 {
     $subject = 'http://example.com';
     $url = new Net_URL2($subject);
     $url->setPath('0');
     $url->normalize();
     $this->assertSame("{$subject}/0", (string) $url);
 }
开发者ID:rafalwojciechowski,项目名称:news,代码行数:18,代码来源:URL2Test.php


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