首页路由与 URLUrl 生成
Url 生成
Kuoqi\Url(357 行):url() 函数底层,INFO_MODE 分支与静态资源
本页内容
  1. tolink 分发逻辑
  2. tolinkWithnormal 规则
  3. 废弃方法

tolink 分发逻辑

条件行为
自身含 host原样 path+query,前缀 scheme://host[:port](完整链接,不做路由修正)
INFO_MODE == 1tolinkWithnormal(false):不带主入口(隐藏 index.php)
其它(含 0)tolinkWithnormal(true):带主入口 /index.php

tolinkWithnormal 规则

  • 以当前请求 Route 为底,setPath/setRoutes 重组路由
  • 先试 Route::routeEncode(命中自定义路由则替换 {id},剩余参数转 query)
  • 否则 Route::toUrl() = getPathDeep + ? + 额外参数 query
  • $origin:true 前缀 scheme://host[:port];字符串作为自定义前缀
  • 静态资源(.js/.css)后缀被剥离($STATIC_EXTS)
典型用法
url("Index/Index");                                  // /index.php/Index/Index
url("Index/Index", array("page" => 2));               // /index.php/Index/Index?page=2
url("Index/Index", array(), true);                    // http://host/index.php/Index/Index
url("Module/Controller/Action", array("id" => 1));    // 完整三段

// Url 对象
$url = new \Kuoqi\Url("/index.php/Home/Goods/Detail");
$url->setQuery("id", 5);
echo $url->tolink();

废弃方法

tolinkWithparams()/tolinkWithroute()/getQueryByarray() 内部引用不存在的 $this->route,调用即异常,勿使用。
KuoqiPHP v1.05 · 离线静态文档 · 界面基于 KuoqiUI · 返回首页