[PHP] Default value if parameter is not passed in
Right now, I'm tweaking a function that has a bunch of optional parameters. I would like to be able to set a default value for the very last one if it is not passed in. This essentially looks like: if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r|ssl, link, arg1, arg1_len, arg2, arg2_len, long, long_len) == FAILURE { RETURN_FALSE; } if (!long || long==NULL) { long=DEFAULT_VALUE; } However, what I found when printing out the value of long is that it has been set to 1?! I imagine this was by the zend_parse_parameters function. Is there a way to disable it from setting values to optional parameters? --Quanah -- Quanah Gibson-Mount Principal Software Developer ITSS/Shared Services Stanford University GnuPG Public Key: http://www.stanford.edu/~quanah/pgp.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Default value if parameter is not passed in
--On Wednesday, October 27, 2004 4:53 PM -0700 Vail, Warren [EMAIL PROTECTED] wrote: I notice that none of your variables use the PHP convention of $ preceding the variable name, I also do not see you defining a value for DEFAULT_VALUE, which by the upper case convention seems to be referring to a global constant. Is it not true (no pun intended) that if a variable (or constant) has not been defined, that assigning the contents of that variable (or value of the constant) will return a false (i.e. a 1)? This is inside the C source code for PHP. C does not prefix variables with a $. The DEFAULT_VALUE was simply shorthand for what I'm setting it to, and is not representative of an actual value, and that bit doesn't particularly matter, since it was never getting executed (although it was for a global constant from a header file). --Quanah -- Quanah Gibson-Mount Principal Software Developer ITSS/Shared Services Stanford University GnuPG Public Key: http://www.stanford.edu/~quanah/pgp.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP 5.0.2 LDAP SASL Binds (GSSAPI specifically)
I see that php 5.0.2 has added the ldap_sasl_bind function. I compiled php-5.0.2 against our OpenLDAP w/ SASL support libraries, and went ahead to give it a whirl: #!/usr/local/bin/php ?php $ds = ldap_connect(ldap-test3.stanford.edu); if($ds) { $r = ldap_sasl_bind($ds); } else { echo Unable to connect!; } ? However, what I get back is: bWarning/b: ldap_sasl_bind() [a href='function.ldap-sasl-bind'function.ldap-sasl-bind/a]: Unable to bind to server: Not Supported in b/afs/ir.stanford.edu/users/q/u/quanah/cgi-bin/test.cgi/b on line b5/bbr / In looking at the php 5.0.2 code I see: if ((rc = ldap_sasl_interactive_bind_s(ld-link, NULL, NULL, NULL, NULL, LDAP_SASL_QUIET, _php_sasl_interact, NULL)) != LDAP_SUCCESS) { This line seems a bit bogus to me -- All those nulls mean that a valid SASL Mechanism is never specified to bind as. For example, in perl, I've used: ldap_sasl_interactive_bind_s($self-{ld}, $dn, $pass, $self-{saslmech}, $self-{saslrealm}, $self-{saslauthzid}, $self-{saslsecprops}, $self-{saslflags}); (Note that for SASL/GSSAPI, the $dn $pass can safely be ignored, as it is my K5 credentials that determine my DN anyhow). Is this feature expected to work yet? --Quanah -- Quanah Gibson-Mount Principal Software Developer ITSS/Shared Services Stanford University GnuPG Public Key: http://www.stanford.edu/~quanah/pgp.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php