我试着从一个URL访问一个ID
网址:
Routes.php
$routes->get('details/(:any)', 'Car::details/$1')
Car.php(控制器)
class Car extends BaseController
{
public function details($id)
{
$carsModel = new carsModel();
$query = $carsModel->findAll();
$data = [
'title_meta' => view('partials/title-meta', ['title' => 'Cars']),
'page_title' => view('partials/page-title', ['title' => 'Vehicles', 'li_1' => 'Home', 'li_2' => 'Cars']),
'carsList' => $query
];
return view('details', $data);
}
引用css的部分标头
<!-- preloader css -->
<link rel="stylesheet" href="assets/css/preloader.min.css" type="text/css" />
<!-- Bootstrap Css -->
<link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
<!-- Icons Css -->
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
<!-- App Css-->
<link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />
我可以在详细信息页面上获得ID,但CSS和页面布局未加载,URL变成这样
http://localhost:8080/CI4/public/details/assets/css/bootstrap.min.css而不是http://localhost:8080/CI4/public/assets/css/bootstrap.min.css
1条答案
按热度按时间yk9xbfzb1#
您可以使用文档www.example.com中显示的
$this->request->uri->getSegment(3)
https://codeigniter.com/user_guide/incoming/incomingrequest.html#the-request-url。以及
遇到未捕获的异常类型:错误异常消息:过滤器变量():向参数#3传递空值($options)
错误,你需要检查php版本和php.ini文件.删除
;
为一些扩展名如mbstring, openssl, gd
,并确保extension_dir
没有被注解删除;
之前.如果错误仍然发生,更新您的 composer .