致命错误:找不到类"adLDAP" [英] Fatal error: Class 'adLDAP' not found

查看:142
本文介绍了致命错误:找不到类"adLDAP"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看的文件称为examples.php,其中包含以下代码:

The file I'm viewing is called examples.php and contains the following code:

include (dirname(__FILE__) . "/adLDAP.php");
try {
    $adldap = new adLDAP();
}

显示的错误为:

Fatal error: Class 'adLDAP' not found in /var/www/examples.php on line 14

第14行是:

$adldap = new adLDAP();

adLDAP.php与examples.php在同一文件夹中,并包含adLDAP类.

adLDAP.php is in the same folder as examples.php and contains the adLDAP class.

我弄乱了我的include语句吗?我尝试了其他格式的没有这样的文件或目录".感觉好像我缺少明显的东西.

Have I messed up my include statement? I get "no such file or directory" with the other formats I have tried. Feels like I'm missing something obvious.

adLDAP.php尽早实例化adLDAP类:

adLDAP.php instantiates the adLDAP class early on:

<?php
namespace adLDAP;

require_once(dirname(__FILE__) . '/collections/adLDAPCollection.php');
require_once(dirname(__FILE__) . '/classes/adLDAPGroups.php');
require_once(dirname(__FILE__) . '/classes/adLDAPUsers.php');
require_once(dirname(__FILE__) . '/classes/adLDAPFolders.php');
require_once(dirname(__FILE__) . '/classes/adLDAPUtils.php');
require_once(dirname(__FILE__) . '/classes/adLDAPContacts.php');
require_once(dirname(__FILE__) . '/classes/adLDAPExchange.php');
require_once(dirname(__FILE__) . '/classes/adLDAPComputers.php');

class adLDAP {

推荐答案

adLDAP类定义在adLDAP命名空间中.您需要告诉PHP此类在此名称空间中:

adLDAP class definition is in adLDAP namespace. You need to tell PHP that this class is in this namespace:

$adldap = new adLDAP\adLDAP();

您也可以使用use关键字导入此类:

You can also import this class with use keyword:

<?php
    include (dirname(__FILE__) . "/adLDAP.php");
    use adLDAP\adLDAP;

    $adldap = new adLDAP;

这篇关于致命错误:找不到类"adLDAP"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆