您好,我想知道是否有办法使用php来调用css文件并将数据插入其中.目的是允许用户轻松修改css文件,而不必手动进入文件.它将是一个名为Width的字段:带有一个文本区域供他们输入.
当然.您可以轻松地读取文件,file_get_contents然后将其写回文件file_put_contents.
// load the css file into a string
$css = file_get_contents("my.css");
// make changes, e.g....
$css = str_replace("width: 10px;", "width: 20px;", css);
// save those changes
file_put_contents("my.css", $css);
Run Code Online (Sandbox Code Playgroud)