Undefined property [closed]

0
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Model_Usuario extends CI_Model {

    function __contruct(){
        parent::__contruct();
        $this->load->database();
    }

    function getPerfil(){
        $query = $this->db->query('SELECT * FROM perfil');
        return $query->result();
    }

}



<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Usuario extends CI_Controller {

    function __contruct(){
        parent::__contruct();
        $this->load->model('Model_Usuario');

    }

    public function index(){
        $data['contenido']="usuario/index";
        $data['getPerfil']=$this->Model_Usuario->getPerfil();
        $this->load->view('plantilla',$data);
    }

}
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Usuario::$Model_Usuario

Filename: controllers/Usuario.php

Line Number: 14

Backtrace:

File: C:\xampp\htdocs\crud-ci3\application\controllers\Usuario.php
Line: 14
Function: _error_handler

File: C:\xampp\htdocs\crud-ci3\index.php
Line: 315
Function: require_once


An uncaught Exception was encountered

Type: Error

Message: Call to a member function getPerfil() on null

Filename: C:\xampp\htdocs\crud-ci3\application\controllers\Usuario.php

Line Number: 14

Backtrace:

File: C:\xampp\htdocs\crud-ci3\index.php
Line: 315
Function: require_once
    
asked by Gerardino 13.08.2017 в 01:32
source

1 answer

0

The problem is that the constructor is never called because it is poorly written, therefore the property you are trying to use will never be defined.

  

__ construct instead of __ contruct

Source: link

    
answered by 13.08.2017 / 15:34
source