首页 文章

致命错误 - Require_once

提问于
浏览
0

我收到以下错误:

警告:require_once(C:\ xampp \ htdocs \ mvc \ public \ views \ home \ init.php):无法打开流:C:\ xampp \ htdocs \ mvc \ public \ index.php中没有此类文件或目录第3行致命错误:require_once():在C中打开所需的'C:\ xampp \ htdocs \ mvc \ public \ views \ home \ init.php'(include_path ='C:\ xampp \ php \ PEAR')失败:第3行\ xampp \ htdocs \ mvc \ public \ index.php

在Index.php中,我的代码是

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

在init.php中,我的代码是

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

在controller.php中:

<?php
class controller
{
}
?>

在app.php中

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

我的文件夹路径是:

htdocs \ mvc \ app \ views \ home \ init.php htdocs \ mvc \ app \ core \ app.php&controller.php htdocs \ mvc \ public \ index.php

有人请帮忙吗?我试过require_once(_DIR . “”);同样但不工作 .

3 回答

  • 0

    试试这个:

    首先对 index.php 文件中的文件路径执行 echo ,如 -

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

    然后检查路径是否正确 . 如果没有,则相应地更改它,然后使用 require_once 中的路径 .

  • 0

    您还可以测试目录和文件本身的权限 . 如果只读权限,则可能存在执行文件的问题 .

  • 0

    恢复公用文件夹中的index.php文件....错误将清除 .

相关问题