Reasons and solutions to the failure of loading CSS and JS files in the PHP CI framework

Source: Internet
Author: User

When the HTML page is integrated into the CI framework, the loading of CSS and JS fails. The reason is that the CI framework is the portal frame

All requests for files in the framework need to be processed by index.php, and when loading external CSS and JS files, the

Use the Base_url () function to handle external links.

You need to load the URL-related class first in the controller


Public Function test () {$this->load->helper (' url '); $this->load->view (' admin/test ');}

In the view view of test.php.


can be used

<link rel= "stylesheet" href= "<?php Echo Base_url ();? >css/min.css "/>

<?php echo Base_url (); The statement outputs the basic pathname.

Need to be declared in configuration file config.php

$config [' Base_url '] = ' http://127.0.0.1/company/';


This will load properly.








Reasons and solutions to the failure of loading CSS and JS files in the PHP CI framework

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.