array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.ldap-errno.php', 1 => 'ldap_errno', ), 'up' => array ( 0 => 'ref.ldap.php', 1 => 'LDAP 函数', ), 'prev' => array ( 0 => 'function.ldap-err2str.php', 1 => 'ldap_err2str', ), 'next' => array ( 0 => 'function.ldap-error.php', 1 => 'ldap_error', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/ldap/functions/ldap-errno.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
ldap_errno — Return the LDAP error number of the last LDAP command
Returns the standardized error number returned by the last LDAP command. This number can be converted into a textual error message using ldap_err2str().
Return the LDAP error number of the last LDAP command for this link.
版本 | 说明 |
---|---|
8.1.0 |
现在 ldap 参数接受 LDAP\Connection
实例,之前接受有效的 ldap link resource。
|
Unless you lower your warning level in your php.ini sufficiently or prefix your LDAP commands with @ (at) characters to suppress warning output, the errors generated will also show up in your HTML output.
示例 #1 Generating and catching an error
<?php
// This example contains an error, which we will catch.
$ld = ldap_connect("localhost");
$bind = ldap_bind($ld);
// syntax error in filter expression (errno 87),
// must be "objectclass=*" to work.
$res = @ldap_search($ld, "o=Myorg, c=DE", "objectclass");
if (!$res) {
echo "LDAP-Errno: " . ldap_errno($ld) . "<br />\n";
echo "LDAP-Error: " . ldap_error($ld) . "<br />\n";
die("Argh!<br />\n");
}
$info = ldap_get_entries($ld, $res);
echo $info["count"] . " matching entries.<br />\n";
?>