douqufan9148 2018-07-02 05:04
浏览 34
已采纳

如何使用codeigniter更改网址中的函数名称?

I want to change the function name in the url, i searched for this a lot but unable to find any solution, can any one help me out what should i do consider for example i have a url like

http://localhost/codeIgniter_try/index.php/Blog/blogvieww ,

so here "Blog" is the controller name and "blogvieww" is the function name so if i want to change the function name from "blogvieww" to "blogvieww_all" what can i do?

Blog.php

   <?php  
        defined('BASEPATH') OR exit('No direct script access allowed');  

        class Blog extends CI_Controller {  

            public function index()  
            {  
                $this->load->view('blogview');  
            }

            public function blogvieww()  
            {  
                $this->load->view('blogvieww');  
            }
        }  
    ?>

blogview.php

    <html>
        <head>
                <title>My Blog</title>
        </head>
        <body>
            <div>
                <h1>Welcome to my 1st Blog!</h1>
            </div>    
        </body>
    </html>

blogvieww.php

    <html>
        <head>
                <title>My Blog</title>
        </head>
        <body>
            <div>
                <h1>Welcome to my 2nd Blog!</h1>
            </div>

            <div>
                <h1>Welcome to my 3rd Blog!</h1>
            </div>
        </body>
    </html>
  • 写回答

4条回答 默认 最新

  • dongqie7806 2018-07-02 05:14
    关注

    Hope this will help you :

    Add the below line of code in your route.php

    $route['Blog/blogvieww_all'] = 'Blog/blogvieww';
    

    Your anchor should be like this :

    <a href=<?=site_url('Blog/blogvieww_all');?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序