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

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

  • 写回答

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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?