用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1806|回复: 2
收起左侧

谁能帮我看看 我的扩展类哪里写错了吗?

[复制链接]
发表于 2012-9-17 10:34:02 | 显示全部楼层 |阅读模式
MY_Cart.php
PHP复制代码
 
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Cart extends CI_Cart {
        public function __construct($params = array())
        {
                parent::__construct($params);
        }
       
        public function pt() {
               
                echo 'Oh,year!';       
        }
 
}
 
复制代码


控制器文件
PHP复制代码
 
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
class Page extends CI_Controller {
 
        public function index()
        {
                $this->load->library('cart');
                $this->cart->pt();
        }
 
}
 
复制代码


Fatal error: Call to undefined method CI_Cart::pt() in D:\wamp\www\ci\application\controllers\page.php on line 8
发表于 2012-9-17 12:26:21 | 显示全部楼层
位置放错了maybe
发表于 2012-10-16 10:07:41 | 显示全部楼层
你的MY_Cart.php放在哪个目录了?如果是放在application/libraries下的话就应该是正确的,能够输出Oh,year!

本版积分规则