Welcome Guest, Not a member yet? Register   Sign In
error creating library
#1

[eluser]samitrimal[/eluser]
hi I am new in codeigniter. when i tried to create a library it shows error. heres my code


application/libraries/Someclass.php
Code:
class Someclass  {
    function  Something(){
        echo 'hello';
    }
}
application/controllers/MainController.php
Code:
class MainController extends Controller{

    function MainController(){

        parent::Controller();
    }
    function index(){
        $this->load->library('Someclass');
        $this->Somclass->Something();
    }

}
It shows the following error
Fatal error: Call to a member function Something() on a non-object in I:\xampp\htdocs\examcontroller\system\application\controllers\MainController.php on line 14
#2

[eluser]Ihab Khattab[/eluser]
I think when you need to access your method you should use the lower case version of your library name

Code:
$this->somclass->something();
#3

[eluser]LuckyFella73[/eluser]
Don't know - maybe it's just a typo:
Code:
<?php
function index(){
        $this->load->library('Someclass');
        $this->Som[missing 'e' here]class->Something();
}
?>




Theme © iAndrew 2016 - Forum software by © MyBB