多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ## 构造Web页面URL createWebUrl() **例如** ~~~ {php echo $this->createWebUrl('goods', array('op'=>'edit'));} ~~~ **生成** ~~~ ./index.php?c=site&a=entry&op=edit&do=goods&m=hx_apicms ~~~ **原型** ~~~ protected function createWebUrl($do, $query = array()) { $query['do'] = $do; $query['m'] = strtolower($this->modulename); return wurl('site/entry', $query); } ~~~ > strtolower() 函数把字符串转换为小写 ~~~ function wurl($segment, $params = array()) { list($controller, $action, $do) = explode('/', $segment); $url = './index.php?'; if (!empty($controller)) { $url .= "c={$controller}&"; } if (!empty($action)) { $url .= "a={$action}&"; } if (!empty($do)) {`` $url .= "do={$do}&"; } if (!empty($params)) { $queryString = http_build_query($params, '', '&'); $url .= $queryString; } return $url; } ~~~ > explode() 函数把字符串打散为数组 > http_build_query — 生成 URL-encode 之后的请求字符串 | 参数 | | | -- | -- | | $do | string |要进入的操作名称对应当前模块的 doWebXxx 中的 Xxx| |$query |array |附加的查询参数 | | 返回值 | | | -- | -- | | string | Url |