【发布时间】:2020-01-29 10:59:12
【问题描述】:
我正在尝试在 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;
这是config.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。
【问题讨论】:
-
我认为你写错了构造函数。
-
你的代码是对的,但是你打错了url,你的url应该是
http://192.168.1.136/dashboard/Projects/CodeIgniter-3.1.11/index.php/calls/index/1,其中1是call_id。
标签: php codeigniter uri