php - 找不到 Php 致命错误类
问题描述
我正在尝试调试一个正在运行但由于某种原因停止的 php 网站的问题。当我尝试通过 http 访问该网站时,它不起作用,所以我检查了 Linux 中的服务器日志,这就是我得到的:
PHP Fatal error: Uncaught Error: Class 'HomePageBanner' not found
文件开头有代码
<?php
require_once 'config.php';
include "checkiflogin.php";
$condition = "";
$objDreamVacationGallery = new HomePageBanner();
$data = $objDreamVacationGallery->selectAllRecords($condition, $sort_field, $sort_order, $start, $limit);
?>
index.php 存储在根目录中,而 HomePageBanner 存储在 root/classes 中。HomePageBanner 的代码看起来像
<?php
class HomePageBanner extends DataBase
{
public $db_table = 'tblxxx';
public $data = '';
public function __construct($data=''){ /* VALUE ASSIGNMENT */
parent::__construct();
if($data!=''){
$this->data = $data;
}
}
public function __destruct(){
parent::__destruct();
}
将不胜感激任何帮助。谢谢
解决方案
您需要先 require_once homepagebanner 类,如下所示
require_once('classes/HomePageBanner.php');
正如我在评论中看到的那样,您正在使用 linux 确保代码中的情况与您的目录中的情况classes
相同HomePageBanner
/var/www/html
推荐阅读
- azure - 将本地 asp.net 核心 Web 应用程序发布到 azure 应用程序服务
- sql - IDENTITY SEED 基于其他表种子值递增
- php - 加速 PHP 脚本
- javascript - 映射数组内的增量值
- reactjs - 有没有更好的方法来设置函数来响应钩子useState?
- javascript - 如何在反应js中单独编辑多个文本输入编辑器字段
- javascript - Char 是 UTF 但我仍然看到加密的字母
- ios - 将 Swift 框架导入到 Obj-C
- ethernet - 符合 IEEE 802.3bt 的低功耗 PD
- entity-framework-core - 如何使用 .NET CORE 3.1 代码优先方法在两列组合上添加唯一键约束?