即使在require_once文件中也找不到php类

时间:2015-02-13 00:21:29

标签: php class

我有一个奇怪的问题。在Plans.php文件中有一些Plans类,它包含在主php中,但似乎没有被系统加载。

看,这里是action.php文件

<?php

// action.php gets 3 parameters:
//  - CONTROLLER: one on AUTH, SYSTEM, USER, ADS 
//  - ACTIVITY: one on LOGIN, PLANS, CONTACTS, GUESTS, CONFIG, MESSAGES
//  - ACTION: LIST, VIEW, EDIT, INSERT, UPDATE

include './config/config.php';
include './utils/Connect_db.php';
require_once './model/Plans.php';
require_once './controllers/MainController.php';
require_once './controllers/AuthController.php';
require_once './controllers/UserController.php';
require_once './classes/ValidateUser.php';

if (class_exists('Plans')) {
    error_log('action: Plans exists');
} else {
    error_log('action: Plans NOT exists');
}

if (class_exists('AuthController')) {
    error_log('action: AuthController exists');
} else {
    error_log('action: AuthController NOT exists');
}

$main = new MainController();

?>

我已经设置了一些 class_exists 函数来检查计划类是否已加载。

这是error_log文件输出:

[13-Feb-2015 01:04:39 Europe/Brussels] action: Plans NOT exists
[13-Feb-2015 01:04:39 Europe/Brussels] action: AuthController exists

显然,稍后使用Plans类会导致计划类未找到

这是您的Plans.php文件:

<?php

class Plans {

    private $_con;
    private $_sql;

    function __construct($users_id, $plans_id) {

        $this->_con = Connect_db();

        switch(func_num_args()) {
            case 0:
                break;
            case 1: // One argument to be users_id
                $this->_sql = "(SELECT u.users_nic, g.status, p.*"
                ." FROM users u, plans p LEFT JOIN guests g"
                ." ON g.plans_id=p.plans_id AND g.users_id=p.users_id"
                ." WHERE u.users_id=p.users_id AND p.users_id=".$users_id.")"
                    . " UNION"
                    . " (SELECT u.users_nic, g.status, p.*"
                ." FROM plans p, users u, guests g"
                ." WHERE u.users_id=p.users_id AND g.plans_id=p.plans_id"
                ." AND g.users_id=".$_users_id." AND p.users_id!=".$users_id." )"
                    ." ORDER BY día DESC";
                break;
            case 2: // Two arguments to be users_id y plans_id
                $this->_sql = "SELECT u.users_nic, g.status, p.*"
                ." FROM users u, plans p"
                ." LEFT JOIN guests g"
                ." ON g.plans_id=p.plans_id AND g.users_id=".$users_id
                ." WHERE u.users_id=p.users_id AND p.plans_id=".$plans_id;
                break;
        }

    } 

    function __destruct(){
        // TO DO
        mysqli_close($this->_con);
    }

    public function dir() {

        $res = mysqli_query($this->_con, $this->_sql)
            or die("Fallo de Consulta");

        $arrSalida = array();

        while ($fila = mysqli_fetch_array($res)) {
            $arrSalida[] = $fila;
        }

        return $arrSalida;

    }
}
?>

这门课有什么问题?完成切换以使用一个或两个参数实现__construct。存在模型文件夹,文件名称正确。

希望有人可以提供帮助。感谢。

1 个答案:

答案 0 :(得分:0)

令人难以置信的是,我的PHP代码中的问题出现在隐藏字符中。我删除了文件并创建了一个新的文件,无需复制/粘贴再次输入代码,问题就消失了。可悲的是,我没有保留文件来分析它与另一个文本编辑器,我可以看到坏的角色。