當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。