PHP - 包含后找不到类

时间:2015-02-23 08:11:11

标签: php class include

我已经搜索了关于这个问题的答案,但它并没有解决我的问题。

我已经包含了这些课程

include "class/config.class.php";
include "config/config.php";
include "class/db.mssql.class.php";

check_login.php

当我尝试登录时,在我输入用户名和密码后,它什么也没做。相反,当我使用firebug时它显示错误。

Fatal error: Class 'cfgConn' not found in D:\wamp\www\mapis\config\config.php on line 2

这就是config.php的样子..

<?php
$cfgConn = new cfgConn();

$confMs = $cfgConn->getConf("mssql_configuration");
$dbHostMs     = $confMs['host'];
$dbPortMs     = $confMs['port'];
$dbNameMs     = $confMs['dbName'];
$dbUserMs     = $confMs['user'];
$dbPasswordMs = $confMs['pass'];

这是config.php

的路径
D:\wamp\www\mapis\config\config.php

我没看到错误在哪里。在我将WAMP从2.2更改为2.4之前,网络正常,之后就会发生这种情况。

注意:class/config.class.php包含在内。它不显示错误,而是显示Firebug的输出。

有人能告诉我我的代码有什么问题吗?

附加:

这是cfgConn类定义的,文件名是config.class.php

<?
    class cfgConn
    {
        function getConf($chs)
        {
            switch($chs)
            {
                //SQLServer Connection
                case "mssql_configuration" : {

                            $c['host']   = "IT-KUNTO";
                            $c['dbName'] = "MAP";
                            $c['port']   = "";
                            $c['user']   = "rafi";
                            $c['pass']   = "P@ssw0rd";

                        }break;
            }
            return $c;
        }
    }
?>

1 个答案:

答案 0 :(得分:0)

config.php文件中包含config.class.php这样的内容。

<?php
    include "class/config.class.php";
    $cfgConn = new cfgConn();

    $confMs = $cfgConn->getConf("mssql_configuration");
    $dbHostMs     = $confMs['host'];
    $dbPortMs     = $confMs['port'];
    $dbNameMs     = $confMs['dbName'];
    $dbUserMs     = $confMs['user'];
    $dbPasswordMs = $confMs['pass'];