我在开发网站的激活页面时遇到了一些麻烦......
我有3页,config.inc.php,functions.inc.php和activate.php
在activate.php上我需要config.inc.php并包含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;
}
}
这是我的档案:link
任何人都可以帮助我吗?
答案 0 :(得分:0)
如果您已设置要导入的文件,请尝试将其置于功能
function ativar_conta($hash, ldap) {}
在activate.php上确保你有config.inc.php并按正确的顺序包含functions.inc.php,这样你就不会在另一个文件之前调用一个依赖项的文件。
如果没有看到其他页面,我就无法对你的问题发表评论。