,我发现了以下错误:致命错误:require_once():
Warning: require_once(D:/xampp/htdocs/inc/head.php): failed to open stream: No such file or directory in D:\xampp\htdocs\ecommerce1\index.php on line 3
Fatal error: require_once(): Failed opening required 'D:/xampp/htdocs/inc/head.php' (include_path='.;D:\xampp\php\PEAR') in D:\xampp\htdocs\ecommerce1\index.php on line 3
我有下面的代码:位于D:\xampp\htdocs\ecommerce1 Index.php
<!--head-->
<?php $title="Gamer"?>
<?php require_once $_SERVER["DOCUMENT_ROOT"]. '/inc/head.php';?>
<?php require_once $_SERVER["DOCUMENT_ROOT"]. '/inc/menu.php';?>
<!--body of the page-->
<!--footer of the page-->
<?php require_once $_SERVER["DOCUMENT_ROOT"]. '/inc/footer.php';?>
`
这是位于D:\xampp\htdocs\ecommerce1\inc
的head.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><?php print $title ?> </title>
<link rel="stylesheet" type="text/css" href="/css/style.css">
<script type="text/javascript" src="/jquery/jquery-1.12.3.min.js"></script>
</head>
<body>
对不起,我有点新来的PHP - 我应该粘贴这个代码,因为它不会做任何事情 –
其实你需要做'<?php require_once $ _SERVER [“DOCUMENT_ROOT”]。 'ecommerce1/inc/head.php';?>等等for others'或者<?php require_once'inc/head.php';?>等等为别人' –
可能重复的[无法打开流:没有这样的文件或目录](http://stackoverflow.com/questions/36577020/failed-to-open-stream-no-such-file-或目录) –