3
I need to use libraries in Codeigniter version 2.1.4 and I have problems 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 code line, controller returns the following error:
"Call to a Member Function test() on a non-object".
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;
}
}
Your code is
$a = $this->Nomedabiblioteca->teste();
or"$a = $this->Nomedabiblioteca->teste();"
?– Oeslei
Use the function
var_dump
to check the propertyNomedabiblioteca
:var_dump($this->Nomedabiblioteca);
– Oeslei
the code is $a = $this->Pathname->test();
– Weslley
var_dump returns null in the property. Undefined Property
– Weslley