【发布时间】:2011-08-17 17:09:14
【问题描述】:
我必须说,我正在使用 PHP 实现 LDAP,这相当容易。但是我有一个关于使用die() 或检查函数返回的问题。从下面的代码 (taken from here),如果您使用 die() 和 ldap_connect,检查 $ldapconn 的意义何在?如果ldap_connect 出现问题,PHP 不应该以die() 退出吗?
// connect to ldap server
$ldapconn = ldap_connect("ldap.example.com")
or die("Could not connect to LDAP server.");
if ($ldapconn) {
// binding to ldap server
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
// verify binding
if ($ldapbind) {
echo "LDAP bind successful...";
} else {
echo "LDAP bind failed...";
}
}
【问题讨论】: