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


PHP Host::getHost方法代码示例

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


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

示例1: DatabaseException

 /**
  * @param Host $_host
  * @param string $_database
  * @param Credential $_credential
  * @param Logger $_logger
  */
 function __construct(Host $_host, $_database, Credential $_credential, Logger $_logger = null)
 {
     $this->logger = $_logger;
     $this->connection = mysql_connect($_host->getHost(), $_credential->getUsername(), $_credential->getPassword(), true);
     if (!$this->connection) {
         throw new DatabaseException(mysql_error($this->connection));
     }
     /* ## LOGGER ## */
     if (isset($this->logger)) {
         $this->logger->DEBUG('mysql_connect: ' . $_host->getHost());
     }
     $selected = mysql_select_db($_database, $this->connection);
     if (!$selected) {
         throw new DatabaseException(mysql_error($this->connection));
     }
     /* ## LOGGER ## */
     if (isset($this->logger)) {
         $this->logger->DEBUG('mysql_select_db: ' . $_database);
     }
 }
开发者ID:keil,项目名称:phpDBI-MySQL-Database-Interface-,代码行数:26,代码来源:Connection.class.php

示例2: testHost

 public function testHost()
 {
     $route = new Host("/");
     $this->assertEquals("", $route->getHost());
     // returns "" ? or it should be NULL / FALSE ?
     $this->assertSame(null, $route->getHost());
     $route->setHost("example.com");
     $this->assertEquals("example.com", $route->getHost());
     $route->setHost(null);
     $this->assertEquals("", $route->getHost());
     $this->assertSame(null, $route->getHost());
     // wrong but will be fixed
     // EDIT: this will not be fixed!
     // $route->setHost("http://example.com/users/list?page=1");
     // $this->assertEquals("example.com", $route->getHost());
     // sub domain
     $route->setHost("sub.example.com");
     $this->assertEquals("sub.example.com", $route->getHost());
     // check parameterized hosts
     $route->setHost("{subdomain}.example.com");
     $this->assertEquals("{subdomain}.example.com", $route->getHost());
 }
开发者ID:sugiphp,项目名称:routing,代码行数:22,代码来源:HostTest.php


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