sent to php.pecl.dev and php.internals
--------------------------

I'm building an extension that will need to register multiple (approx 250
(up to 48 chars per string)) strings as constants. I would rather not
clutter up the namespace with all these constants so I was wondering what
would the recommended way to achieve this would be?

A. Should I normalize the constants by mapping them to int's and create a
few ZEND_FUNCTION(ext_import_*_constants) functions and use SET_VAR_LONG()
and internally have a static char *php_ext_map_constant(int c) that maps the
php int constants to a string?
B. Go all out and use REGISTER_STRING_CONSTANT[L]()  in the ext's startup?
C. Or, just create an include php file with all the constants defined()'d
from php code and distribute with ext or package as PEAR?
D. Ignore constants and let the users type the string themselves.

I noticed one other ext (syslog) that does something like this with
define_syslog_variables(). I also toyed with the idea of creating
zend_object's that hold these constant to avoid cluttering up the namespace
but I need this to work for php 4-5 and I'm not sure that 4 supports
read-only class variables. Any thoughts on this would be appreciated.
Thanks,

--
Justin Hannus
Lead Programmer/Web Development
[EMAIL PROTECTED]
www.visualconceptsinc.com
[860] 242.1150 ext.125
[860] 242.1446 fax

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to