Home > Article > PHP Framework > 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/");
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.
<link href="<?php echo (css_url)?>User_Login.css" type="text/css" rel="stylesheet" />
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!