[英]In codeigniter controller is not being called and its giving a blank page
我有很多博客。 我试图找到一种解决方案,为什么控制器不加载页面并显示空白页面。 但是我觉得它没有用。 但是代码在localhost中可以正常工作。 我不知道为什么会这样。 无法找到解决方案。 任何帮助,将不胜感激。
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Config_test extends CI_Controller {
public function __construct(){
parent::__construct();
if( $this->session->userdata('logged_in') != TRUE ){
redirect('login?reurl='.current_url());
}elseif (!$this->usergroup_model->page_allowed()) {
//This check will ensure that only authorised users can have access to any
//functions present in this controller
//Route all control requests only through config function only
show_error('The url is either wrong or the inputs are inadquate. Please navigate with the help of menu bar only...');
die();
}
$this->moduleID = '3';
$this->menu['main_menus'] = $this->usergroup_model->menu_access();
$this->menu['sub_menus'] = $this->usergroup_model->submenu_access($this->moduleID);
$this->menu['module_name'] = $this->usergroup_model->module_name($this->moduleID);
$this->load->vars($this->menu);
$this->load->model('model_1');
$this->load->model('model_2');
$this->load->model('model_3');
}
function index(){
$this->config();
}
function config($action=null)
{
//If customer ID is null... redirect to dashboard...
if($this->session->userdata('dashboard_customer_id') == null)
redirect('dashboard');
switch ($action)
{
case 'add':
$this->add();
break;
case 'add_save':
$this->add_save();
break;
case 'add_success':
$this->add_success();
break;
case 'edit':
$this->edit();
break;
case 'edit_save':
$this->edit_save();
break;
case 'edit_success':
$this->edit_success();
break;
default:
$this->edit();
break;
}
}
function add()
{
//doing some function
}
function add_save()
{
//some code
}
function add_success()
{
//some code
}
function edit()
{
//some code
}
function edit_save()
{
//some code
}
function edit_success()
{
//Not used here...
}
}
这是我的网址http://localhost/tester/index.php/Config_test
可能是未在服务器上启用mod_rewrite
。
在服务器上启用mod_rewrite
该问题可能是由许多想法引起的,例如缺少php扩展名。 您是否查看过错误日志。 也许如果您提供更多信息,我可以为您提供帮助。 您在localhost和实时系统中使用的php版本是什么。
Apache默认情况下区分大小写,因此:
http://localhost/tester/index.php/Config_test
应该是小写的:
http://localhost/tester/index.php/config_test
当然,请保持控制器类名称大写。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.