php – 404找不到codeigniter网址
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php – 404找不到codeigniter网址,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1347字,纯文字阅读大概需要2分钟。
内容图文
![php – 404找不到codeigniter网址](/upload/InfoBanner/zyjiaocheng/824/0638c30a9a7e4dc5a6eda9ff558cbdfd.jpg)
我是一个使用codeigniter的初学者.我使用以下URL“http://localhost/ci/index.php/shopcart”访问控制器,我收到错误404页面未找到
控制器代码
<?php
class Cart extends CI_Controller { // Our Cart class extends the Controller class
function Cart()
{
parent::CI_Controller(); // We define the the Controller class is the parent.
}
}
function index()
{
$this->load->model('cart_model'); // Load our cart model for our entire class
$data['products'] = $this->cart_model->retrieve_products(); // Retrieve an array with all products
$data['content'] = 'cart/products'; // Select our view file that will display our products
$this->load->view('index', $data); // Display the page with the above defined content
}
?>
型号代码
<?php
class Cart_model extends Model { // Our Cart_model class extends the Model class
// Function to retrieve an array with all product information
function retrieve_products(){
$query = $this->db->get('products'); // Select the table products
return $query->result_array(); // Return the results in a array.
}
}
路线
$route['default_controller'] = "shopcart";
自动加载
$autoload['libraries'] = array('cart' , 'database');
$autoload['helper'] = array('form');
解决方法:
codeigniter适用于base_url~ / index.php / class_nm / function / segment3.现在在您的情况下更改文件名Cart.php.
localhost/ci/index.php/cart/index
并确保您的功能索引是公开的,我想它会解决您的问题:)
内容总结
以上是互联网集市为您收集整理的php – 404找不到codeigniter网址全部内容,希望文章能够帮你解决php – 404找不到codeigniter网址所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。