Home  >  Article  >  PHP Framework  >  How to introduce css files in yii framework

How to introduce css files in yii framework

王林
王林Original
2019-12-13 16:27:483167browse

How to introduce css files in yii framework

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

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

define("css_url", "http://127.0.0.1/yii/shop/assets/default/css/"); The first parameter is the system environment Variable name, the second parameter is the corresponding file path

3. After the environment variables are configured, we also need to introduce the file function.php## of the system environment we just configured into our project entry file. #

require dirname(__FILE__).'./protected/config/function.php';

Since the system environment variables we configure for css, js, and img are all configured in the function, we only need to introduce them once in the entry file of the project.

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

<link href="<?php echo (css_url)?>User_Login.css" type="text/css" rel="stylesheet" />

Recommended related articles and tutorials:

yii tutorial

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

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