Codeigniter控制器未返回请求的功能 [英] Codeigniter controller not returning requested function
问题描述
我在CodeIgniter中有一个控制器,它不响应我的请求.当我向它添加一个简单函数test1 { echo'test';}
时,它返回空白响应.当我将此功能添加到另一个控制器时,它会按预期返回测试".无效控制器的语法与有效控制器的语法没有区别:
I have a controller in CodeIgniter that does not respond to my requests. When I add a simple function to it function test1 {echo 'test';}
, it returns blank response. When I add this function to another controller, it returns 'test' as expected. The syntax for the invalid controller does not differ from a valid one:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class authorized extends CI_Controller
{
function index(){echo "test";}
function __construct()
{
parent::__construct();
//Load Neccessary Models
$this->load->model('users');
$this->load->model('manufacturers');
$this->load->model('suppliers');
$this->load->model('administrators');
$this->load->model('banks');
//End Load Neccessary Models
define("AUTHORIZENET_API_LOGIN_ID", "");
define("AUTHORIZENET_TRANSACTION_KEY", "");
define("AUTHORIZENET_MD5_SETTING", "");
$this->load->library('authorizenet');
}
function test1(){echo "test";}
}
其不响应的原因可能是什么?
What can be the reason for its not responding?
推荐答案
好的,通过确保控制器内的函数顺序如下来使其起作用:函数__construct(),然后是函数index(),然后是我需要的函数test1().
Alright, got it to work by ensuring there is the following order of functions within the controller: function __construct(), then function index(), then my required function test1().
这篇关于Codeigniter控制器未返回请求的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!