dpdx51205 2016-04-14 08:31
浏览 105
已采纳

致命错误 - Require_once

I am getting the following error:

Warning: require_once(C:\xampp\htdocs\mvc\public\views\home\init.php): failed to open stream: No such file or directory in C:\xampp\htdocs\mvc\public\index.php on line 3

Fatal error: require_once(): Failed opening required 'C:\xampp\htdocs\mvc\public\views\home\init.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\mvc\public\index.php on line 3

In Index.php, my code is

<?php
require_once __DIR__ . '\views\home\init.php';
$app= new app;
?>

In init.php, my code is

<?php require_once __DIR__ . '\core\app.php';
 require_once  __DIR__ . '\core\controller.php';

In controller.php:

<?php
class controller
{
}
?>

In app.php

<?php
class app
{
public function _construct() 
{
    echo 'now what';
}
}
?>

My folder paths are:

htdocs\mvc\app\views\home\init.php

htdocs\mvc\app\core\app.php & controller.php

htdocs\mvc\public\index.php

Anybody please help? i have tried require_once (_DIR . ""); as well but not working.

  • 写回答

4条回答 默认 最新

  • doude2635 2016-04-14 08:37
    关注

    Try this:

    First do echo for the file path in index.php file like -

    echo __DIR__ . '/views/home/init.php';
    

    And then check whether the path is correct or not. If not, then change it accordingly and then use the path in require_once.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程