CodeIgniter Forums
Why doesn't this library load in my controller? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Why doesn't this library load in my controller? (/showthread.php?tid=9874)



Why doesn't this library load in my controller? - El Forum - 07-11-2008

[eluser]Aquillyne[/eluser]
This is the file "stylesheet.php", which is in the subfolder "utilities" in my "controllers" folder.

Code:
<?php

class Stylesheet extends Controller
{

    function Stylesheet()
    {
        parent::Controller();
    }
    
    
    function foo()
    {
        $this->load->library("CSS");
        $this->CSS->select("body");
    }
    
}

?>

When I go to index.php/utilities/stylesheet/foo I get the error:

Quote:Fatal error: Undefined property: Stylesheet::$CSS. Call to a member function select() on a non-object in C:\Server\Frameworks\CodeIgniter\application\controllers\utilities\stylesheet.php

The "CSS" library is a custom library in my application's "libraries" folder. Its contents are:

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

class CSS {

    function select($element)
    {

    }
    
}

?>

So as you can see, I am trying to load a custom library which contains the function "select" - but although I get no error message for the loading of the library, calling this select method just doesn't work!

Please help! Thanks.


Why doesn't this library load in my controller? - El Forum - 07-11-2008

[eluser]arume[/eluser]
It's because you use upper case in the CSS library name. Call it css and it will be OK.