我已经为 php 网站构建了我的简单模板。问题是我不知道包含我的 css 和 javascript 文件的好方法。
这是我的index.php文件
<?php
include'core/template.php';
$temp=new Template();
$settings=array("title","page_title","welcome_word");
$values=array("RIS - Home","Results Information System","Welcome to result
Information system");
$temp->header($settings,$values);
$temp->footer();
?>
这是我的template.php文件
<?php
class Template {
public function header($setting,$values){
$file=file_get_contents("http://localhost/RIS/src/header.php");
$count=0;
foreach ($setting as $setting) {
$file=str_replace('{'.$setting.'}',$values[$count],$file);
$count++;
}
echo $file;
}
public function footer(){
$file=file_get_contents("http://localhost/RIS/src/footer.php");
echo $file;
}
}
?>
这是我的header.php文件
<!DOCTYPE html>
<html>
<head>
<title>{title}</title>
</head>
<body>
<header>
<h1>{page_title}</h1>
{welcome_word}
</header>
My contents goes here...
这是我的footer.php文件
<footer>
Copyright © RIS 2013.
</footer>
</body>
</html>
我有我的 css 文件和 js 文件在assets 文件夹中 ,那么我如何将它们包含在我的模板中?