Fatal error: Call to a member function ola () on a non-object

3

I need to use libraries in Codeigniter version 2.1.4 and I'm having trouble using these libraries myself. After loading the library (with $this->load->library('Nomedabiblioteca'); in my controller ), I have the line of code:

$a = $this->Nomedabiblioteca->teste();

To receive the return of the method teste() of the class. However, in this line of code, the controller returns the following error:

  

How can I resolve this situation? What am I doing wrong?

The library code is as follows (code for testing):

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

class Nomedabiblioteca{
    public function teste(){
        $a = 'algo';
        return $a;
    }
}
    
asked by anonymous 11.06.2015 / 22:43

1 answer

1

I was able to solve by changing the class name of

$a = $this->Nomedabiblioteca->teste(); //Capitalizada

To

$a = $this->nomedabiblioteca->teste();

By all means codeigniter does not work for libraries the same way as for controllers, models and views.

    
12.06.2015 / 07:21