我正在尝试将 projects.php 文件加载到更高级别的 index.php 文件中,并希望维护所有 .js .css 和任何进一步嵌套(在 .js 文件中)的 .php 文件,这些文件在projects.php 文件。
我的 index.php 文件是这样的:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>BLST</title>
</head>
<body>
<?php $projectsPage = "/tables/php/projects.php"?>
<li><a href="index.php?page=<?php echo $projectsPage;?>">Projects</a></li>
<?php if(is_null($_GET["page"])) {
$page = "";
}else{
$page = $_GET["page"];
}
include($page);
?>
</body>
</html>
我的projects.php文件是
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Projects</title>
<style type="text/css">
@import "css/test.css";
@import "http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.23/themes/smoothness/jquery-ui.css";
</style>
<script type="text/javascript" language="javascript" charset="utf-8" src="js/jquery.min.js"></script>
</head>
问题是找不到 projects.php 中的任何文件。这是因为浏览器现在正在查找我的主目录(index.php 所在的位置)。
最佳答案
test.css在“tables/php/css/test.css”中,projects.php和index.php的位置呢
我认为这些问题的答案将解决问题。
关于php - 使用 PHP include 将文件包含在它自己的包含文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22618759/