本文整理匯總了PHP中Basic::safeUrl方法的典型用法代碼示例。如果您正苦於以下問題:PHP Basic::safeUrl方法的具體用法?PHP Basic::safeUrl怎麽用?PHP Basic::safeUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Basic
的用法示例。
在下文中一共展示了Basic::safeUrl方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
protected function __construct()
{
if (isset($_SERVER['REQUEST_URI'])) {
$this->full_url_path = $_SERVER['REQUEST_URI'];
} elseif (isset($_SERVER['argv'])) {
$this->full_url_path = $_SERVER['PHP_SELF'] . '?' . $_SERVER['argv'][0];
} else {
$this->full_url_path = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];
}
$pos = strpos($this->full_url_path, '?');
if ($pos === false) {
$this->url_get = '';
$this->url_path = $this->full_url_path;
} else {
$this->url_get = substr($this->full_url_path, $pos + 1);
$this->url_path = substr($this->full_url_path, 0, $pos);
}
//把連續的“\"或“/”替換成一個“/”
$this->url_path = preg_replace('/[\\/\\\\]+/', '/', $this->url_path);
//去掉末尾的斜杠
$this->url_path = substr($this->url_path, -1) == '/' ? substr($this->url_path, 1, -1) : substr($this->url_path, 1);
$array_urlPath = array();
if ($this->url_path) {
$pos = strpos($this->url_path, '/');
if ($pos === false) {
$array_urlPath = array(0 => $this->url_path);
} else {
$array_urlPath = explode('/', $this->url_path);
}
}
$this->controllerName = isset($array_urlPath[0]) ? strtolower($array_urlPath[0]) : 'index';
$this->actionName = isset($array_urlPath[1]) ? strtolower($array_urlPath[1]) : 'index';
//獲得並設置參數
$this->array_parameter = array();
if (($arrayCount = count($array_urlPath)) > 2) {
for ($i = 2; $i < $arrayCount; ++$i) {
$this->array_parameter[] = Basic::safeUrl($array_urlPath[$i]);
}
}
if (!Singleton::getInstance('RequestModule')->isPost()) {
$this->checkUrl();
}
}