Getting a PHP constant back from it's string name
<p>I'm creating a small LDAP connection class but this applies to PHP constants in general.</p>

<p>PHP has constants like <code>LDAP_OPT_PROTOCOL_VERSION</code>, <code>LDAP_OPT_HOST_NAM</code>, and <code>LDAP_OPT_TIMELIMIT</code> that are used in the following function: </p>

<p><code>ldap_set_option ( $myLdapConnection, LDAP_OPT_PROTOCOL_VERSION, 3 )</code></p>

<p>In my LDAP connection class I want to be able to pass the options in an array like so</p>

<pre>
<code>
array( 
'LDAP_OPT_PROTOCOL_VERSION' => 3,
'LDAP_OPT_TIMELIMIT' => 1000
);
</code>
</pre>

<p>I'd then like to do the following type of loop</p>

<pre>
<code>
foreach( $options as $option => $value ){
      ldap_set_option ( $myLdapConnection, $option, $value );
}
</code>
</pre>

<p>If I try this, however, I get an error that says the function expects a long, not a string. How can I get past this?</p>

<p>EDIT: Bart is right, I realize. I'll do it this way. It'll even be faster because there won't be a string involved.</p>

<p>Just to be clear though, if ever there should be overlap of constants, for example when I define my own constants, then it might be a problem.</p>
