I have tried following way to use of routes and controller and tried to get parameter values from the controller method but I get result $1. but actually, I passed 3.
routes.php
$route['helloword/:any'] = "FirstProgram/helloworld/$1";
controller
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class FirstProgram extends CI_Controller {
public function helloworld($param=''){
$data = array(
'title' => 'Title',
'heading' => 'Heading',
'message' => 'Message',
'param' => $param
);
echo $param;exit;
$this->load->view('FirstProgram', $data);
}
}
?>
更改您的路线代码,只需为:any添加一个括号即可
$route['helloword/(:any)'] = "FirstProgram/helloworld/$1";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.