我有一个PHP类,它有一个私有变量path
。使用类 -
$path = $_SERVER['DOCUMENT_ROOT'].'/PrePress/';
$temp = new Template($path);
$temp->head("Login", "");
班级模板 -
public function head($title, $js_scripts) {
$path = $this->path;
if($js_scripts == NULL) {
$add_script = "";
}
echo "<head>
echo "<link rel='stylesheet/less' type='text/css' href='".$path."less/bootstrap.less'>
<link rel='stylesheet/less' type='text/css' href='".$path."less/prepress.less'>
<script src='".$path."js/less.js'></script>";
echo $add_script;
echo "</head>";
}
$path
中的<link>
变量确实有效,但网址会被http://localhost:8888/$PATH
更改,但找不到。
因为我使用$_SERVER['DOCUMENT_ROOT]
,所以我不希望URL前面的`localhost。我怎么能避免这个?
答案 0 :(得分:0)
你可以尝试这个,一些连接问题已修复
echo "<head>
<link rel='stylesheet/less' type='text/css' href='".$path."less/bootstrap.less.css'>
<link rel='stylesheet/less' type='text/css' href='".$path."less/prepress.less.css'>
<script src='".$path."js/less.js'></script>
".$add_script."
</head>";
答案 1 :(得分:0)
替换代码
echo "<head>
<link rel='stylesheet/less' type='text/css' href='".$path."less/bootstrap.less'>
<link rel='stylesheet/less' type='text/css' href='".$path."less/prepress.less'>
<script src='".$path."js/less.js'></script>";
echo $add_script;
echo "</head>";