,我發現了以下錯誤:致命錯誤: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-或目錄) –