doucong1268
2016-11-01 16:20
浏览 302
已采纳

Xampp / php:找不到文件路径

I use brackets for editing and live previewing my code, but when I change the names of my folders live preview doesn't work. Here is the error message:

Warning: require(header.php): failed to open stream: No such file or directory in D:\Programmering\Xammp\Files\htdocs\webside1\pages\index.php on line 13 Fatal error: require(): Failed opening required 'header.php'

(include_path='D:\Programmering\Xammp\Files\htdocs\webside1\pages/../') in D:\Programmering\Xammp\Files\htdocs\webside1\pages\index.php on line 13

Here is my index.php code:

<!DOCTYPE html>
<html>
    <title>Home - Awt-technologies</title>
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="style.css">
    <script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.js"></script>

    <body id="indexbody">
        <?php //include_once('D:\Programmering\Xammp\Files\htdocs\webside1\pages\header.php');
        set_include_path(dirname(__FILE__)."/../");
        require 'header.php';
        //Checks if user is logged in
        if(isset($_SESSION['name'])) {
            include_once "templates\loggedin.php";
        }
        ?>

    </body>
</html>

I checked the path and it should work but doesn't. Here is a picture of my files in brackets: screenshot

图片转代码服务由CSDN问答提供 功能建议

我使用括号进行编辑和实时预览我的代码,但是当我更改文件夹的名称时,实时预览不会 工作。 以下是错误消息:

警告:require(header.php):无法打开流:D:\ Programmering \ Xammp \ Files中没有此类文件或目录 第13行\ htdocs \ webside1 \ pages \ index.php 致命错误:require():无法打开所需的'header.php'

(include_path ='D:\ Programmering \ 第13行的D:\ Programmering \ Xammp \ Files \ htdocs \ webside1 \ pages \ index.php中的Xammp \ Files \ htdocs \ webside1 \ pages /../' \ n

这是我的index.php代码:

 &lt;!DOCTYPE html&gt; 
&lt; html&gt; 
&lt; title&gt;主页 -  Awt-technologies&lt; /  title&gt; 
&lt; link rel =“stylesheet”href =“http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css”&gt; 
&lt; meta name =“viewport  “content =”width = device-width,initial-scale = 1.0“&gt; 
&lt; link rel =”stylesheet“href =”http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap  -theme.min.css“&gt; 
&lt; link rel =”stylesheet“href =”style.css“&gt; 
&lt; script src =”http://netdna.bootstrap  cdn.com/bootstrap/3.0.0/js/bootstrap.js"></script>
nn&lt; body id =“indexbody”&gt; 
&lt;?php // include_once('D:  \ Programmering \ Xammp \ Files \ htdocs \ webside1 \ pages \ header.php'); 
 set_include_path(dirname(__ FILE __)。“/ ./”); 
需要'header.php'; 
 //检查 如果用户登录
 if(isset($ _ SESSION ['name'])){
 include_once“templates \ loggedin.php”; 
} 
?&gt; 
 
&lt; / body&gt; \  n&lt; / html&gt; 
   
 
 

我检查了路径,它应该有效,但没有。 以下是括号中我的文件的图片:

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douji8017 2016-11-01 16:46
    已采纳

    Your index.php is in a different folder than your header.php file.

    You'll need to change the require path to ../templates/header.php.

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题