链接到另一个页面的代码信号器 [英] codeigniter linking to another page
问题描述
我是新的codeigniter框架。我有href链接的问题。在我的主页我有一些菜单,去不同的页面。例如在正常的php如果我想去书图书页,那么我只是把sellBook.php在href链接。现在在codeigniter如何可以做到这一点。我需要在控制器中写什么吗?
i am new to codeigniter framework. i am having problem with href link. in my home page i have some menu, that goes to different page. for example in normal php if i want to go Sell Books page then i just put sellBook.php in href link. now in codeigniter how can i do this. do i need write something in controller ?
<li ><a href="http://www.studenthint.com/">Home </a> </li>
<li><a href="">Buy Books</a> </li>
<li><a href="sellBook.php">Sell Books</a> </li>
<li><a href="#">Books on Demand</a> </li>
<li><a href="#">Request a Book</a> </li>
<li><a href="#">About Us</a> </li>
推荐答案
例如:
if you, for example, want to link to
> http://www.site.com/users
http://www.site.com/users
,所以控制器看起来像: p>
so the controller will look like:
class Users extends CI_Controller{
function index(){
//do somenthing here
}
function list(){
//list your users
}
}
那么在你的视图中,链接到该控制器很简单:
then in your views linking to that controller is simple:
<a href="<?php echo site_url('users'); ?>">this will link to your users controller and index() method</a>
<a href="<?php echo site_url('users/list'); ?>">this will link to your users controller and list() method</a>
site_url方法将帮助你找到正确的链接,如果
你正在使用index.php或不在你的urls
the site_url(); method will helps you finding the right link both if you are using index.php or not in your urls
这篇关于链接到另一个页面的代码信号器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!