首页 > 解决方案 > 找不到 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();
        }

将不胜感激任何帮助。谢谢

标签: phpmysqllinux

解决方案


您需要先 require_once homepagebanner 类,如下所示

require_once('classes/HomePageBanner.php');

正如我在评论中看到的那样,您正在使用 linux 确保代码中的情况与您的目录中的情况classes相同HomePageBanner/var/www/html


推荐阅读