简体   繁体   English

致命错误:找不到类“ adLDAP”

[英]Fatal error: Class 'adLDAP' not found

The file I'm viewing is called examples.php and contains the following code: 我正在查看的文件称为examples.php,其中包含以下代码:

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

The error that displays reads: 显示的错误为:

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

Line 14 is: 第14行是:

$adldap = new adLDAP();

adLDAP.php is in the same folder as examples.php and contains the adLDAP class. adLDAP.php与examples.php在同一文件夹中,并包含adLDAP类。

Have I messed up my include statement? 我是否弄乱了我的include语句? I get "no such file or directory" with the other formats I have tried. 我尝试了其他格式的“没有这样的文件或目录”。 Feels like I'm missing something obvious. 感觉像我缺少明显的东西。

adLDAP.php instantiates the adLDAP class early on: adLDAP.php尽早实例化adLDAP类:

<?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 {

etc. 等等

adLDAP class definition is in adLDAP namespace. adLDAP类定义位于adLDAP名称空间中。 You need to tell PHP that this class is in this namespace: 您需要告诉PHP此类在此命名空间中:

$adldap = new adLDAP\adLDAP();

You can also import this class with use keyword: 您也可以use关键字导入此类:

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

    $adldap = new adLDAP;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM