Home>Article>PHP Framework> Solve the problem that ThinkPHP styles cannot be loaded (CSS, JS)
The followingthinkphpframework tutorial column will introduce to you how to solve the problem of ThinkPHP style failure to load (CSS, JS). I hope it will be helpful to friends in need!
1. Project entry file index.php
2. Add the following code to the project configuration file APP/Conf/config.php
'TMPL_PARSE_STRING' => array( '__PUBLIC__' =>__ROOT__.'/APP/Tpl/Public', '__JS__' => __ROOT__.'/APP/Tpl/Public/Js', '__CSS__' => __ROOT__.'/APP/Tpl/Public/Css', ),Previously, the CSS configured here was
'__CSS__' => __PUBLIC__.'/Css'
Then there was the problem of being unable to load CSSROOTis a system constant, indicating the root directory address of the website. For example, my localhost is set to E:\www In this place, and then create the ThinkPHPbbs project in E:\www\ThinkPHPbbs, thenROOTindicates localhost/ThinkPHPbbs
JS settings are the same as
3 .Configure html
CSS:JS :
The normal loading effect is as shown
The file structure is as shown in the figure
(The red crosses in front of some folders will not affect the entire operation, the editor is zend studio)It is recommended that if you encounter a situation where the style cannot be loaded If there is a problem, you can check the path of the link. For example, I configured it as follows
'__CSS__' => __PUBLIC__.'/Css'
If you check the web page elements, it will be displayed as follows
HerePUBLICis not parsed out
Configure it like later
'__CSS__' => __ROOT__.'/APP/Tpl/Public/ Css'
View style
Parse normally
The above is the detailed content of Solve the problem that ThinkPHP styles cannot be loaded (CSS, JS). For more information, please follow other related articles on the PHP Chinese website!