假设
我的css文件托管在https://cdn.domain.com/css/style.css
中
现在我的主站点是https://www.domain.com
这里我有一个https://www.domain.com/scripts/source/link.php
中的文件,它只包含cdn站点的URI:
A: https://cdn.domain.com/
现在,在我的索引文件中,我想包括css文件,但使用链接.php文件,如:
B: <link rel="stylesheet" href="<? include 'scripts/source/link.php'; ?>css/style.css" />
我知道以前的代码不会像那样工作
C: <link rel="stylesheet" href="https://cdn.domain.com/css/style.css" />
那么,要实现C,A或b中应该有什么?
解决方案:
在b部分中,
<?php
ob_start();
include "link.php";
$myvar = ob_get_contents();
ob_end_clean();
?>
<link rel="stylesheet" href="<? echo $myvar."style.css";?>" />