Get the App
SLTechnology News&Howtos  ›  Development  › 

The solution of require_once error reporting in php

Shulou Source: shulou.com Published: 2022-06-03 20:23:14 10月03日 Update

This article mainly introduces the solution of require_once error report in php, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.

Php require_once error because the function will put all the code in the CategoryDao.class.php file into the login.php, the solution is: 1, the use of "require_once (" relative path ")"; 2, the path of the file that calls the require_once function.

Operating environment of this article: Windows7 system, PHP7.1 version, Dell G3 computer

What if php require_once reports an error? the correct path cannot be found in php require_once ().

First of all, to describe the problem, when I use the require_once () function, I think that the path configuration is fine, but the web page will still have an error that the path can not be found. The details are as follows:

My project path is as follows:

In the login.php file, I called require_once (". / mysql/CategoryDAO.class.php"); to include the CategoryDao.class.php file, and then called require_once (". / DbConnect.class.php") in the CategoryDao.class.php file; to include the DbConnect.class.php file, and as a result, the browser could not find the target file.

This is because the require_once () function in login.php will put all the code in the CategoryDao.class.php file into the login.php, that is, the login.php file contains all the code in the CategoryDao.class.php file, including require_once (". / DbConnect.class.php"); however, the current directory is the path of login.php, so the path ". / DbConnect.class.php" can not be found, the correct path should be ". / mysql/DBConnect.class.php".

To sum up, when using require_once (relative path), the current path is the path of the last file that called the require_once function.

Thank you for reading this article carefully. I hope the article "the solution to require_once error reporting in php" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Path file function article code method problem put value interest method at the same time what to do situation more friends browser version environment computer Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL NVidia Shulou Information vpn Apple