开发者

editing css files through php

my head was spinning over this idea for a long time . and i though this is the right plce to ask for help .. so what i want to do is make a really simple php file that make a search and replace in css files but the problem that i have is that a single css file can (as you all know ) have a 100 or more background tags and all i want to edit is one of them .. and what is some body added a line before or after ... so search and replace for the whole section of the css file that i want to开发者_JAVA百科 replace well be useless unless it is all the same .. i really have a bad time explanning but i hope that you get the main idea .. all i want is some guidelines in this .. help is really appreciated/


I wouldn't suggest directly editing a linked CSS file through PHP (file_get_contents()) or something, but rather conditionally link different CSS files. Or perhaps, conditionally change what you need to change through CSS directly in HTML with PHP. For example, need to change background (for some reason) for different users, you would conditionally change the image source through PHP.


Why exactly do you want to do this? Maybe a CSS alternative like LESS is a viable option (it has support for variables etc)


You can either use php to load a stylesheet.php that is dynamically generated or use javascript to "compile" it on the client side (like LessCss)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜