如何使用codeIgnator在视图中调用控制器的功能? [英] how to call function of controller in view using codeIgnator?

查看:258
本文介绍了如何使用codeIgnator在视图中调用控制器的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

hi每个人都在这里用codeignator!我有一个控制器如下:
class myController extends CI_Controller {

hi everybody m new here with codeignator!! i have a controller as in the following: class myController extends CI_Controller{

function __constructor(){
    parent::__constructor();
}
public function index(){
    $this->load->view('myview');
}
public function myFn(){
echo "my controller is called"; 
}


}

视图m使用HTML窗体中的形式action m调用myFn通过使用以下链接localhost / Codeignator / myController / myFn
这样做后,我得到以下错误!
在此服务器上找不到请求的URL / CodeIgniter / myController / myFn

and in the view m using a HTML form in the form action m calling the myFn by using the following link localhost/Codeignator/myController/myFn after doing so i got the following error!! The requested URL /CodeIgniter/myController/myFn was not found on this server

但是当我使用链接localhost / Codeignator / index.php / myController / myFn

but when i use the link localhost/Codeignator/index.php/myController/myFn

我获得了正确的输出!

任何人都有帮助我
thnx

anybody is there to help me thnx in advance

推荐答案

默认情况下,index.php文件将包含在您的URL中
参见
用户指南部分删除有关添加.htacces的index.php文件

By default, the index.php file will be included in your URLs see the user guide section Removing the index.php file about adding a .htacces

创建一个包含以下内容的.htaccess文件:

Create a .htaccess file with the following contents:


    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]

并将其放在网站的根文件夹

and put it in the root folder of your site

这篇关于如何使用codeIgnator在视图中调用控制器的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆