Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP未定义变量ldap_Php_Ldap - Fatal编程技术网

PHP未定义变量ldap

PHP未定义变量ldap,php,ldap,Php,Ldap,我在开发我网站的激活页面时遇到一些问题 我有3个页面,config.inc.php、functions.inc.php和activate.php 在activate.php上,我需要config.inc.php和include functions.inc.php 在functions.inc.php上,我还需要config.inc.php 但我有一个错误: Notice: Undefined variable: ldap in D:\xampp\htdocs\pap\inc\functions.

我在开发我网站的激活页面时遇到一些问题

我有3个页面,config.inc.php、functions.inc.php和activate.php

在activate.php上,我需要config.inc.php和include functions.inc.php 在functions.inc.php上,我还需要config.inc.php

但我有一个错误:

Notice: Undefined variable: ldap in D:\xampp\htdocs\pap\inc\functions.inc.php on line 109

Fatal error: Call to a member function getRepository() on null in D:\xampp\htdocs\pap\inc\functions.inc.php on line 109
ldap变量在config.inc.php上定义:

$ldap = new LdapManager($config);
functions.inc.php上的函数

use LdapTools\Object\LdapObjectType;
function ativar_conta($hash)
{
    // First get the user object via a repository.
    $repository = $ldap->getRepository(LdapObjectType::USER);
    $user = $repository->findOneByUsername($login);

    // Make sure the user account is set to enabled.
    $user->setEnabled(true);
    // Set their password to never expire.
    $user->setPasswordNeverExpires(true);

    try 
    {
        $ldap->persist($user);
        echo'teste';
        return true;
    } 
    catch (\Exception $e) 
    {
        echo "Error modifying user! ".$e->getMessage();

        return false;
    }
}
这是我的文件:


有人能帮我吗?

如果您已经设置了要导入的文件,请尝试将其启用

function ativar_conta($hash, ldap) {}
在activate.php上,确保您有config.inc.php,并以正确的顺序包含functions.inc.php,这样您就不会调用一个文件,而该文件在另一个文件之前具有依赖关系


如果看不到其余页面,我就无法对您的问题发表评论。

查看了您的代码。我认为您没有将它导入函数,这就是为什么它会对您大喊大叫,因为它看不到变量。请在上面的答案中尝试我的建议,很高兴这有帮助!