Php – CodeIgniter – Loading CSS


I am developing an custom API for a web solution and I am using the MVC design pattern. I have a modules folder so that I can swap in and out modules and also work on sections without disrupting working tested code. My only issue now is that I want to load CSS anywhere and have my application properly import the css file in the head tag. I know CodeIgniter does this but I'm not sure how.

Using PHP, how do I load in a CSS file anywhere and then have the code properly import the css within the head tags like CodeIgniter does?

Thanks in advance.

Best Solution

You can load several views at once, or views inside other views.

So in this case I recomend you to create one header view where you load all css and js files


    <meta http-equiv="content-type" content="text/html;charset=UTF-8">
    <link rel="stylesheet" href="<?php echo base_url();?>css/moorainbow.css" type="text/css" media="screen"/>

And call it like:


This way you can control the files (css+js+etc) you load in just one file.


Related Question