简体   繁体   English

无法在函数文件PHP中包含类文件

[英]Can't include a class file in functions file PHP

I have this dbconnect.php file that uses a class called DB to do DB operations. 我有这个dbconnect.php文件,它使用一个称为DB的类来执行DB操作。 I have another file that contains some general functions called functions.php. 我还有另一个文件,其中包含一些称为functions.php的常规功能。 This dbconnect file is working well in everywhere but functions.php. 该dbconnect文件在functions.php以外的任何地方都可以正常工作。 What could be the problem? 可能是什么问题呢?

Try using include_once instead of includes. 尝试使用include_once代替include。

Also, it would help if you could c+p the error you are receiving. 此外,如果您可以c + p收到错误,也将有所帮助。

Using include_once instead of include, solved my problem. 使用include_once而不是include解决了我的问题。 I think it was caused because of object orientation. 我认为这是由于面向对象引起的。 My best guess is, when I used include, the class was c/p'd multiple times which interfered the core of object orientation concept. 我最好的猜测是,当我使用include时,该类被c / p多次处理,这干扰了面向对象概念的核心。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM