Newsgroups: php.internals,php.pecl.dev Path: news.php.net Xref: news.php.net php.internals:6294 php.pecl.dev:237 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4692 invoked by uid 1010); 9 Dec 2003 08:32:16 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 4650 invoked from network); 9 Dec 2003 08:32:15 -0000 Received: from unknown (HELO mail.zend.com) (192.117.235.230) by pb1.pair.com with SMTP; 9 Dec 2003 08:32:15 -0000 Received: (qmail 4337 invoked from network); 9 Dec 2003 08:32:13 -0000 Received: from guardian.zend.office (HELO andi-laptop.zend.com) (10.1.1.4) by mail.zend.com with SMTP; 9 Dec 2003 08:32:13 -0000 Message-ID: <5.1.0.14.2.20031209103128.04b4f5d8@127.0.0.1> X-Sender: andi@127.0.0.1 X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Tue, 09 Dec 2003 10:32:02 +0200 To: "Justin Hannus" ,internals@lists.php.net, pecl-dev@lists.php.net In-Reply-To: <20031208185028.23203.qmail@pb1.pair.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: [PHP-DEV] REGISTER_*_CONSTANT() or SET_VAR_*() with multiple strings constants From: andi@zend.com (Andi Gutmans) References: <20031208185028.23203.qmail@pb1.pair.com> I think that as long as you follow the naming standards for constants which are EXTNAME_CONSTANT it should be OK to just define them as regular global constants during MINIT. Andi At 01:45 PM 12/8/2003 -0500, Justin Hannus wrote: >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 >jhannus@visualconceptsinc.com >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