本文整理匯總了PHP中Cx\Core\Routing\Url::fromMagic方法的典型用法代碼示例。如果您正苦於以下問題:PHP Url::fromMagic方法的具體用法?PHP Url::fromMagic怎麽用?PHP Url::fromMagic使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cx\Core\Routing\Url
的用法示例。
在下文中一共展示了Url::fromMagic方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testFileUrls
public function testFileUrls()
{
$testResult = 'file://' . getcwd();
$url = Url::fromRequest();
$this->assertEquals($testResult, $url->toString());
$this->assertEquals(getcwd(), (string) $url);
$url = Url::fromMagic($testResult);
$this->assertEquals($testResult, $url->toString());
$this->assertEquals(getcwd(), (string) $url);
}
示例2: redirect
/**
* Redirect
*
* This function redirects the client. This is done by issuing
* a "Location" header and exiting if wanted. If you set $rfc2616 to true
* HTTP will output a hypertext note with the location of the redirect.
*
* @static
* @access public
* @return mixed Returns true on succes (or exits) or false if headers
* have already been sent.
* @param string $url URL where the redirect should go to.
* @param bool $exit Whether to exit immediately after redirection.
* @param bool $rfc2616 Wheter to output a hypertext note where we're
* redirecting to (Redirecting to <a href="...">...</a>.)
*/
public static function redirect($url, $exit = true, $rfc2616 = false)
{
if (headers_sent()) {
return false;
}
$url = \Cx\Core\Routing\Url::fromMagic($url);
$url = $url->toString();
// use absolute url
self::header('Location: ' . $url);
if ($rfc2616 && isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
printf('Redirecting to: <a href="%s">%s</a>.', $url, $url);
}
if ($exit) {
exit;
}
return true;
}
示例3: resolve
/**
* Resolve
*/
public function resolve(\Cx\Core\Routing\Url $url, &$continue)
{
if (!$this->matches($url)) {
return $url;
}
$continue = $this->getContinueOnMatch();
$newUrl = \Cx\Core\Routing\Url::fromMagic($this->getRegularExpression()->replace($url->toString()));
\DBG::log('Redirecting to ' . $newUrl->toString());
return $newUrl;
}