Fatal error: Class 'adLDAP' not found

2019-07-21 08:55发布

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

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:

$adldap = new adLDAP();

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

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

etc.

标签: php adldap
1条回答
Fickle 薄情
2楼-- · 2019-07-21 09:34

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

$adldap = new adLDAP\adLDAP();

You can also import this class with use keyword:

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

    $adldap = new adLDAP;
查看更多
登录 后发表回答