One last ldap_connect headache

From: Date: Wed, 04 Nov 2015 04:13:35 +0000
Subject: One last ldap_connect headache
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-89066@lists.php.net to get a copy of this message
I got mail from someone saying that in previous version, calling ldap_connect($host, NULL) would use default port. While now it is considered as trying to use port 0 and trigger an error.. I’m a bit troubled about it because the documentation says: resource ldap_connect ([ string $hostname = NULL [, int $port = 389 ]] ) So $port defaults to 389 and not to NULL, and it says nothing about accepting NULL as second parameter. That said, it does seem handful to be able to pass NULL to ask for default port without remembering which one it is. The context is something like: $port = NULL; if (isset($options['port'])) { $port = $options['port']; } $resource = ldap_connect($host, $port); Right now it either needs an if statement or hardcoding 389 instead of NULL as the default. In the C code we use the constant LDAP_PORT for this but there is no such thing in PHP. Any ideas/comments about this? MCMic

« previous php.internals (#89066) next »