我使用CodeIgniter框架,我很困惑如何从我的网址中移除%20。以下是我的代码示例。 控制器 - 博客 方法 - 显示 属性 - 这是我的博客Codeigniter的URI函数url_title()如何使用
public function show($blog= null)
{
// my attempt to set the uri segment
$blogName = $this->uri->segment(3, url_title($blog));
... //other code
}
这并不工作,我很困惑,我实现url_title(“这是我的博客”)功能,使页面加载它显示:
/博客/显示/这 - 是 - 我 - 博客
做我需要做的事情在config/routes.php文件的文件?
谢谢!
编辑:
好吧,让我发现了url_title()输出this20is20my20blog所以我现在有这样的:
$blogUrl = str_replace("%20", "-", $blog);
$this->uri->segment(3, $blogUrl);
,但它仍然%返回的URL 20
没有显示其它代码(例如,什么是“回报”的%20的?),它是不可能知道发生了什么。另外,你说你想让它显示“/ blog/show/this-is-my-blog”,但是你没有指定你浏览的URI是什么,也不是你是否通过$博客参数show()函数。 –