本文整理汇总了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);
}
}
示例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());
}