如何使用PHP codeigniter实现关键字特定的页面调用

如何使用PHP codeigniter实现关键字特定的页面调用</ p>

二进制搜索树实现。 </ p>

例如 在上面的URL关键字“binary-search-tree-implementaion”是特定控制器的方法名称或参数。 因为大多数事情是动态的,那么网站将如何管理所有这些事情?</ p>

我想为我的网站实现这样的事情</ p>

http://example.com/search/digital-camera-price-in -india </ p>
</ div>

展开原文

原文

How to implement keyword specific page invocation using PHP codeigniter

Binary search Tree Implementation.

for e.g. in above URL keyword "binary-search-tree-implementaion" is method name or parameter for specific controller. because most of things are dynamic then how web site is going to manage all those things?

I want to implement it for my web site like this

http://example.com/search/digital-camera-price-in-india

3个回答

I'm not familiar with CodeIgniter, but usually a URI structure like /search/digital-camera-price-in-india would route to the Search controller and digitalCameraPriceInIndia action.

/search/digital-camera-price-in-india

=> SearchController::digitalCameraPriceInIndiaAction()

If you want to route similar URIs (different products for example) to a catch-all method, you've have to setup custom routing.

The CodeIgniter documentation for routing is here

dosc9472
dosc9472 我不为每个查询字符串创建它应该是虚拟的方法
9 年多之前 回复

As per @chriso's answer you will need to set up a custom route to achieve this as by default the uri structure is /controller/action/params. So in your config/routes.php file you can add something like:

$route['search/(:any)'] = "search/some_action";

And then use the relevant uri segment (

$this->uri->segment[1]

I think) as your search parameter.



如果你设置这样的路线:</ p>

  $ route ['^  search /(:any)'] =“search / my_controller_function / $ 1”; 
</ code> </ pre>

然后你可以像这样编写你的函数:</ p>

  public function my_controller_function($ search_input)
{
//您的代码在这里
}
</ code> </ pre>
</ div>

展开原文

原文

if you set up your route like this:

$route['^search/(:any)'] = "search/my_controller_function/$1";

Then you can just write your function like this:

public function my_controller_function($search_input) 
{
 // your code here
}

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问