Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php能否从另一个非php文件(例如.scss或.css)中回显某些单词?_Php_Css_Sass - Fatal编程技术网

php能否从另一个非php文件(例如.scss或.css)中回显某些单词?

php能否从另一个非php文件(例如.scss或.css)中回显某些单词?,php,css,sass,Php,Css,Sass,php能否从另一个非php文件(例如.scss或.css)中回显一个单词 假设我有test.php和test1.scss 在test1.scss上,我的文本如下所示: /*test1.scss内容的开始*/ $theme_名称:MyTheme /*test1.scss内容结束*/ 现在我只想用php代码在test.php上回显MyTheme。可能吗?使用 file_get_contents() 然后使用正则表达式: 这种模式有效。第2组包含“MyTheme” file_get_contents

php能否从另一个非php文件(例如.scss或.css)中回显一个单词

假设我有test.php和test1.scss

在test1.scss上,我的文本如下所示:

/*test1.scss内容的开始*/

$theme_名称:MyTheme

/*test1.scss内容结束*/

现在我只想用php代码在test.php上回显MyTheme。可能吗?

使用

file_get_contents()
然后使用正则表达式:

这种模式有效。第2组包含“MyTheme”


file_get_contents()将外部文件放入字符串中,从中可以使用正则表达式提取单词。读取文件,然后根据需要进行处理。然后回显它谢谢您的评论,还有一个问题我如何回显test1中的“MyTheme”。scs创建正则表达式以查找
$theme\u name:
之间的任何文本凯文普只是说了怎么做。非常感谢你们,你们真是太棒了。:)欢迎如果答案行得通,你可以接受。
$pattern = '/(\$theme_name :)(.*);/';
preg_match($pattern, $a, $results);

echo ($results[2]);