面对 404 页面时,尝试在 Codeighter 中的 url 中传递值时找不到



>我正在尝试在网址中传递值

http://192.168.1.136/dashboard/Projects/CodeIgniter-3.1.11/index.php/calls/call_id

并面对404页面未找到错误。

我想将call_id传递给控制器。请告诉我我做错了什么。

这是控制器

class Calls extends CI_Controller {
// I WANT TO ACCESS call_id HERE
function __construct() {
parent::__construct();
}
public function index($abc) {
$this->load->helper('url');
$call =  $this->uri->segment(3);
$data = array('call_id' => $call, 'bar' => 'world');
$this->load->view('Pages/MyAjax.php', $data);
}
}

这是路由器配置

defined('BASEPATH') OR exit('No direct script access allowed');
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

这是配置.php

defined('BASEPATH') OR exit('No direct script access allowed');
$config['base_url'] = '';
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'REQUEST_URI';
$config['url_suffix'] = '';
$config['language'] = 'english';
$config['charset'] = 'UTF-8';
$config['enable_hooks'] = FALSE;
$config['subclass_prefix'] = 'MY_';
$config['composer_autoload'] = FALSE;
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-';
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd';
$config['allow_get_array'] = TRUE;
$config['log_threshold'] = 0;
$config['log_path'] = '';
$config['log_file_extension'] = '';
$config['log_file_permissions'] = 0644;
$config['log_date_format'] = 'Y-m-d H:i:s';
$config['error_views_path'] = '';
$config['cache_path'] = '';
$config['cache_query_string'] = FALSE;
$config['encryption_key'] = '';
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['cookie_prefix']    = '';
$config['cookie_domain']    = '';
$config['cookie_path']      = '/';
$config['cookie_secure']    = FALSE;
$config['cookie_httponly']  = FALSE;
$config['standardize_newlines'] = FALSE;
$config['global_xss_filtering'] = FALSE;
$config['csrf_protection'] = FALSE;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = TRUE;
$config['csrf_exclude_uris'] = array();
$config['compress_output'] = FALSE;
$config['time_reference'] = 'local';
$config['rewrite_short_tags'] = FALSE;
$config['proxy_ips'] = '';

我想在controller访问call_id。

像这样向index()添加参数index($call_id = NULL)

控制器

class Calls extends CI_Controller {
function __construct() {
parent::__construct();
}
public function index($call_id = NULL) {
// $this->load->helper('url');
// $call =  $this->uri->segment(3);
$data = array('call_id' => $call_id, 'bar' => 'world');
$this->load->view('Pages/MyAjax.php', $data);
}
}

和网址

http://192.168.1.136/dashboard/Projects/CodeIgniter-3.1.11/index.php/calls/index/30

其中,上述网址30中的最后一个片段是call_id

相关内容

  • 没有找到相关文章

最新更新