本文整理汇总了PHP中URL::getPort方法的典型用法代码示例。如果您正苦于以下问题:PHP URL::getPort方法的具体用法?PHP URL::getPort怎么用?PHP URL::getPort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URL
的用法示例。
在下文中一共展示了URL::getPort方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toExternalForm
/**
* @param URL $u
* @return blaze\lang\String
*/
public function toExternalForm(URL $u)
{
$str = $u->getScheme() . '://';
if ($u->getUser() != null) {
$str .= $u->getUser();
if ($u->getPassword() != null) {
$str .= ':' . $u->getPassword();
}
$str .= '@';
}
$str .= $u->getHost();
if ($u->getPort() != -1) {
$str .= ':' . $u->getPort();
}
if ($u->getPath() != null) {
$str .= '/' . $u->getPath();
}
if ($u->getQuery() != null) {
$str .= '?' . $u->getQuery();
}
if ($u->getFragment() != null) {
$str .= '#' . $u->getFragment();
}
return new \blaze\lang\String($str);
}
示例2: __construct
/**
* Constructor
*
* @param util.cmd.ParamString args
*/
public function __construct(ParamString $args)
{
$url = new URL($args->value(0));
// If protocol string does not contain port number, set default.
if (self::ESDL_PORT === $url->getPort(self::ESDL_PORT)) {
$url->setPort(self::ESDL_PORT);
}
// Check given URL to inform user if invalid port used.
if (self::ESDL_PORT !== $url->getPort()) {
Console::$err->writeLine('Notice: using non-standard port ' . $url->getPort() . ', ESDL services are usually available at port 6449.');
}
$this->remote = Remote::forName($url->getURL());
$this->jndi = $args->value(1);
$this->processor = new DomXSLProcessor();
$this->processor->setXSLBuf($this->getClass()->getPackage()->getResource($args->value('lang', 'l', 'xp5') . '.xsl'));
}
示例3: setup
/**
* Setup the class instance. A dsn string must be given with the relevant information
* about the server and script:
*
* Eg: nagios://nagios.xp_framework.net:5667/service_to_monitor
*
* @param string dsn
*/
public function setup($dsn)
{
$url = new URL($dsn);
$this->server = $url->getHost();
$this->port = $url->getPort(5667);
$this->version = $url->getParam('version', NSCA_VERSION_2);
$this->service = trim($url->getPath(), '/');
$this->host = $url->getParam('hostname', System::getProperty('host.name'));
if (FALSE !== $url->getParam('domain', FALSE)) {
$this->host .= '.' . ltrim($url->getParam('domain'), '.');
}
}
示例4: newSocket
/**
* Creates a socket
*
* @param peer.URL url
* @param string arg
* @return peer.Socket
*/
protected function newSocket(URL $url, $arg)
{
return new Socket($url->getHost(), $url->getPort(80));
}
示例5: testGetPort
/**
* @covers \URLParser\URL::__construct
* @covers \URLParser\URL::getPort
*/
public function testGetPort()
{
$url = new URL($this->testUrl);
$this->assertEquals($this->port, $url->getPort());
}
示例6: newSocket
/**
* Creates a socket - overridden from parent class
*
* @param peer.URL url
* @param string arg
* @return peer.Socket
*/
protected function newSocket(URL $url, $arg)
{
sscanf($arg, 'v%d', $version);
return new SSLSocket($url->getHost(), $url->getPort(443), NULL, $version);
}
示例7: ipv6AddressAndPort
public function ipv6AddressAndPort()
{
$u = new URL('http://[::1]:8080');
$this->assertEquals('[::1]', $u->getHost());
$this->assertEquals(8080, $u->getPort());
}
示例8: navigateTo
/**
* Navigate to a given URL
*
* @param string target
* @param string params
* @param string method
* @throws unittest.AssertionFailedError
*/
public function navigateTo($target, $params = NULL, $method = HttpConstants::GET)
{
if (strstr($target, '://')) {
$url = new URL($target);
$this->conn = $this->getConnection(sprintf('%s://%s%s/', $url->getScheme(), $url->getHost(), -1 === $url->getPort(-1) ? '' : ':' . $url->getPort()));
$params ? $url->setParams($params) : '';
$this->beginAt($url->getPath(), $url->getParams(), $method);
} else {
if ('' !== $target && '/' === $target[0]) {
$this->beginAt($target, $params, $method);
} else {
$base = $this->getBase();
$this->beginAt(substr($base, 0, strrpos($base, '/')) . '/' . $target, $params, $method);
}
}
}
示例9: _parsedsn
/**
* Parse DSN
*
* @param string dsn
* @return bool success
*/
protected function _parsedsn($dsn)
{
if (NULL === $dsn) {
return TRUE;
}
$u = new URL($dsn);
if (!$u->getHost()) {
throw new IllegalArgumentException('DSN parsing failed ["' . $dsn . '"]');
}
// Scheme
switch (strtoupper($u->getScheme())) {
case 'ESMTP':
$this->ext = TRUE;
break;
case 'SMTP':
$this->ext = FALSE;
break;
default:
throw new IllegalArgumentException('Scheme "' . $u->getScheme() . '" not supported');
}
// Copy host and port
$this->host = $u->getHost();
$this->port = $u->getPort() ? $u->getPort() : 25;
// User & password
if ($u->getUser()) {
$this->auth = $u->getParam('auth', SMTP_AUTH_PLAIN);
$this->user = $u->getUser();
$this->pass = $u->getPassword();
}
}