Localhost出错

时间:2016-04-08 11:44:00

标签: php

我在index.php中有代码

<?php $title ="League of Draven" ?>
<?php require_once $_SERVER["DOCUMENT_ROOT"] . '/inc/head.php';?>
<?php require_once $_SERVER["DOCUMENT_ROOT"] . '/inc/menu.php';?>
<?php require_once $_SERVER["DOCUMENT_ROOT"] . '/inc/footer.php';?>

在head.php中

<!DOCTYPE html>
<html>
<head>
<title> <?php print $title ?></title>
<link rel="stylesheet" type="text/css" href="/css/style.css"/>
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
</head>
<body>

当我尝试在浏览器中打开时,我发现此错误:

 Warning: require_once(C:/xampp/htdocs/inc/head.php): failed to open stream: No such file or directory in C:\xampp\htdocs\Myshop\index.php on line 6

 Fatal error: require_once(): Failed opening required 'C:/xampp/htdocs/inc/head.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\Myshop\index.php on line 6

1 个答案:

答案 0 :(得分:0)

我猜您没有为此项目创建虚拟主机,因此$_SERVER["DOCUMENT_ROOT"]将指向C:\xampp\htdocs\而不是C:\xampp\htdocs\Myshop

为了避免这种情况,您可以使用以下inc文件夹中的以下内容来说明当前正在运行此代码的<?php $title ="League of Draven" require_once './inc/head.php'; require_once './inc/menu.php'; require_once './inc/footer.php'; 文件夹

set.seed(2133)
df <- data.frame(a = paste(sample(1:9, 5, replace=T), sample(c("", "%2", "%3"), 5, replace=T),  sample(c("", "%3", "%4"), 5, replace=T), sep="")) 
df
      a
1     6
2 2%3%4
3   6%2
4   3%2
5 5%2%4