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