2017-05-03 29 views
0

我有一个问题,当我将展示这样 enter image description here与笨错误通知

的通知号码,这是我的看法nombre.php:

<?php 
    $CI =& get_instance(); 

    $CI->load->model("notif_model"); 

    $notification = new notif_model(); 

    $notifications = $notification->countNotif(); 
    echo $notifications; 

?> 

,并创建应用程序的文件Controller.php这样/ core:

<?php 
    class Controller extends ci_controller{ 

    static function &get_instance() 
    { 
     return CI_Controller::get_instance(); 
    } 
} 

?> 
+0

https://www.codeigniter.com/user_guide/general/creating_libraries.html?highlight=library和https://www.codeigniter.com/user_guide/general/controllers.html#class-constructors – user4419336

回答

1

问题有点不清楚。但是,您并未使用框架正确的方式。试试这个方法:

在APPPATH.'controllers/Some_controller.php '

<?php 

class Some_controller extends CI_Controller 
{ 
    public function __construct() 
    { 
     parent::__construct(); 
     $this->load->model("notif_model"); 
    } 

    public function index() 
    { 
     $data['notifications'] = $this->notif_model->countNotif(); 
     $this->load->view('some/index', $data); 
    } 

} 

在APPPATH.'views /一些/ index.php文件'

<?php 
var_dump($notifications); 

你有很多的错误是不在编码范围内。检查框架需要的编码标准(即文件名/类名)。 Docs