Home> PHP Framework> YII> body text

How to reference css in yii framework

王林
Release: 2019-11-06 15:35:35
Original
2532 people have browsed it

How to reference css in yii framework

Method steps:

1. We create a file directory under the assets directory in the shop directory (I take default as an example), and create a css under default. File directory, place our css file directly under this directory.

2. We create a php file in the shop/protected/config directory (I take function.php as an example) and create system variables in the file.

define("css_url", "http://127.0.0.1/yii/shop/assets/default/css/");
Copy after login

Parameter description: The first parameter is the variable name of the system environment, and the second parameter is the corresponding file path.

3. After the environment variables are configured, we also need to introduce the system environment file function.php and require dirname(__FILE__) we just configured into our project entry file.' ./protected/config/function.php'; Since the system environment variables we configure for css, js, and img are all configured in function, it only needs to be introduced once in the entry file of the project.

4. The last step is to witness whether it is successful. We can just output the environment variables we configured in the template of the style we want to introduce directly.

Copy after login

Recommended tutorial:yii tutorial

The above is the detailed content of How to reference css in yii framework. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!