Home >Backend Development >PHP Tutorial >Reasons and solutions for failure to load css and js files in the php ci framework, _PHP tutorial

Reasons and solutions for failure to load css and js files in the php ci framework, _PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:21:581030browse

The reasons and solutions for failure to load css and js files in the php ci framework,

When integrating the html page into the ci framework, loading css and js failed. After a long time, I found that the ci framework is the entrance framework,

All requests for files in the framework need to be processed by index.php. When loading external css and js files,

Use the base_url() function to handle external links.

For example:

The base_url in the config configuration file is: "localhost:8080/project name/"

Access the application/resource/aaa.js file in the controller

Relative path2da1ef0a2cbf6a8da3c511edec2ba6cd2cacc6d41bbb37262a98f745aa00fbf0Access failed

1. Output directly in src

<script src= "<&#63;php echo base_url();&#63;>.resource/aaa.js"></script>

2. Borrow base tag

Put the output of base_url() inside the

tag

It is more convenient to call it on the page.

<base href = "<&#63;php echo base_url();&#63;>"/>
<script src= "resource/aaa.js"></script>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/852378.htmlTechArticleThe reasons and solutions for failure to load css and js files in the php ci framework, integrating the html page into the ci framework When inside, loading css and js failed. After working for a long time, I found that the ci framework is the entrance frame...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn