简体   繁体   English

警告:require_once(../initialize.php):无法打开 stream 和致命错误:require_once():无法打开所需的问题

[英]Warning: require_once(../initialize.php): failed to open stream and Fatal error: require_once(): Failed opening required problem

I am running my system to 000webhost and this issue pops out when I open it我正在将我的系统运行到 000webhost,当我打开它时会弹出这个问题

Warning: require_once(../initialize.php): failed to open stream: No such file or directory in /storage/ssd4/040/17993040/public_html/EPS/classes/DBConnection.php on line 3警告:require_once(../initialize.php):无法打开 stream:/storage/ssd4/040/17993040/public_html/EPS/classes/DBConnection.php 行中没有这样的文件或目录

Fatal error: require_once(): Failed opening required '../initialize.php' (include_path='.:/usr/share/pear:/usr/share/php') in /storage/ssd4/040/17993040/public_html/EPS/classes/DBConnection.php on line 3致命错误:require_once():在 /storage/ssd4/040/17993040/public_html 中打开所需的 '../initialize.php' (include_path='.:/usr/share/pear:/usr/share/php') 失败/EPS/classes/DBConnection.php 在第 3 行

and this are the code files这是代码文件

DBConnection.php DBConnection.php

<?php
if(!defined('id17993040_epsdb')){
    require_once("../initialize.php");
}
class DBConnection{

    private $host = "local_host";
    private $username = "id17993040_root";
    private $password = "********";
    private $database = "id17993040_epsdb";
    
    public $conn;
    
    public function __construct(){

        if (!isset($this->conn)) {
            
            $this->conn = new mysqli($this->host, $this->username, $this->password, $this->database);
            
            if (!$this->conn) {
                echo 'Cannot connect to database server';
                exit;
            }            
        }    
        
    }
    public function __destruct(){
        $this->conn->close();
    }
}
?>

initialize.php初始化.php

    <?php
$dev_data = array('id'=>'-1','firstname'=>'Developer','lastname'=>'','username'=>'dev_oretnom','password'=>'**********','last_login'=>'','date_updated'=>'','date_added'=>'');
if(!defined('base_url')) define('base_url','https://web-silverconcha.000webhostapp.com/EPS/');
if(!defined('base_app')) define('base_app', str_replace('\\','/',__DIR__).'/' );
if(!defined('dev_data')) define('dev_data',$dev_data);
if(!defined('DB_SERVER')) define('DB_SERVER',"localhost");
if(!defined('DB_USERNAME')) define('DB_USERNAME',"id17993040_root");
if(!defined('DB_PASSWORD')) define('DB_PASSWORD',"************");
if(!defined('DB_NAME')) define('DB_NAME',"id17993040_epsdb");
?>

What are the solutions to this?有什么解决方案? Sorry for asking just a newbie很抱歉只问一个新手

UPDATE: This was the filesystem filedir更新:这是文件系统文件目录

filedir2文件目录2

filedir3文件目录3

PHP throws a fatal error when you are using require_once() and it doesn't find the file, which causes script to stop, unlike include_once() which will only show you a warning that it could not find the file. PHP 在您使用require_once()并且找不到文件时会引发致命错误,这会导致脚本停止,这与include_once()不同,它只会向您显示找不到文件的警告。

So it's simply telling you " I can't find the file that you asked for in line 3"所以它只是告诉你“我在第 3 行找不到你要求的文件”

You can try你可以试试

$realPath = realpath($_SERVER["DOCUMENT_ROOT"]);

require_once("$realPath/initialize.php");

Highly recommend to read and learn more about these:强烈建议阅读并了解有关这些的更多信息:

realpath真实路径

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PHP致命错误:require_once():必须打开失败 - PHP Fatal error: require_once(): Failed opening required PHP致命错误:require_once():必须打开失败 - PHP Fatal error: require_once(): Failed opening required 警告无法打开流权限拒绝致命错误require_once PHP + NginX + RHEL in VMware - Warning failed to open stream permission denied fatal error require_once PHP + NginX + RHEL in VMware 致命错误:require_once():需要打开失败 - Fatal error: require_once(): Failed opening required 致命错误:require_once():需要打开失败 - Fatal error: require_once(): Failed opening required 致命错误:require_once():XAMPP中要求打开失败 - Fatal error: require_once(): Failed opening required in XAMPP Codeigniter 新手:致命错误:require_once():需要打开失败 - Codeigniter for newbie : Fatal error: require_once(): Failed opening required 致命错误:require_once():需要打开失败 - Fatal error: require_once(): Failed opening required PHP警告:require_once:无法打开流:在目录中没有这样的文件或目录 - PHP Warning: require_once: failed to open stream: No such file or directory in PHP 警告:require_once 无法打开流:中没有这样的文件或目录 - PHP Warning: require_once failed to open stream: No such file or directory in
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM