Php 本地主机中的错误
我在index.php中有代码Php 本地主机中的错误,php,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"]
<?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';?>
我猜您尚未为此项目创建虚拟主机,因此$\u服务器[DOCUMENT\u ROOT]将指向C:\xampp\htdocs\而不是C:\xampp\htdocs\Myshop 为了避免这一点,您可以使用下面的inc文件夹中的require,我目前正在运行此代码,无论从何处运行此代码
<?php
$title ="League of Draven"
require_once './inc/head.php';
require_once './inc/menu.php';
require_once './inc/footer.php';
在你的例子中,我一次也没有看到一个要求。至少显示相关代码,否则我们无法帮助我们,我们没有透视能力,这也不起作用。我在htdoc文件夹中创建了一个文件夹Myshop index.php文件。在Myshop中,我创建了另一个文件夹inc,在其中我放置了head.php文件。请参阅修改后的答案
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
<?php
$title ="League of Draven"
require_once './inc/head.php';
require_once './inc/menu.php';
require_once './inc/footer.php';