使用 file() 获取网站的 css 代码


Get css code of website with file()

我有这个代码:

$path = $site."/".$stylesheets[0] ("http://example.com/thecssfile.css")
$css = file($path);

但是现在,$css变量中有 http://example.com 的源代码。如何获取 http://example.com/thecssfile.css 代码。如果我将$path变量直接设置为"http://example.com/thecssfile.css",它可以工作,但我希望它是动态的。

你假设,$stylesheets[0]thecssfile.css,但事实并非如此。您可以通过var_dump($stylesheets[0])看到这一点

你需要确保,它有你想要的价值。在您的情况下:

$stylesheets = [0 => 'thecssfile.css']