Codeigniter controller not returning requested function

為{幸葍}努か 提交于 2019-12-25 06:32:51

问题


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?


回答1:


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().



来源:https://stackoverflow.com/questions/23569210/codeigniter-controller-not-returning-requested-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!