Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:9846 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48617 invoked by uid 1010); 13 May 2004 20:42:02 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 48593 invoked from network); 13 May 2004 20:42:02 -0000 Received: from unknown (HELO home.sklar.com) (24.199.89.64) by pb1.pair.com with SMTP; 13 May 2004 20:42:02 -0000 Received: from sklar.com ([127.0.0.1]) by home.sklar.com with Microsoft SMTPSVC(6.0.2600.1106); Thu, 13 May 2004 16:42:00 -0400 Message-ID: <40A3DD98.107@sklar.com> Date: Thu, 13 May 2004 16:42:00 -0400 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7b) Gecko/20040421 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Marcus Boerger CC: internals@lists.php.net References: <40A3CC7E.3070207@sklar.com> <1711326829.20040513215615@marcus-boerger.de> In-Reply-To: <1711326829.20040513215615@marcus-boerger.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 13 May 2004 20:42:00.0481 (UTC) FILETIME=[BD8DC110:01C4392A] Subject: Re: [PHP-DEV] Internal zvals can't be arrays From: sklar@sklar.com (David Sklar) I think your humor is too subtle for me. I don't understand what you mean. If I do this: PHP_METHOD(test_class,__construct); zend_class_entry *test_class_ce_ptr = NULL; static zend_function_entry test_class_functions[] = { PHP_ME(test_class, __construct, NULL, ZEND_ACC_PUBLIC) {NULL, NULL, NULL} }; And then I put this in my MINIT function: INIT_CLASS_ENTRY(ce, "test_class", test_class_functions); test_class_ce_ptr = zend_register_internal_class(&ce TSRMLS_CC); zend_declare_property_null(test_class_ce_ptr, "test_property", sizeof("test_property")-1, ZEND_ACC_PUBLIC TSRMLS_CC); And I make test_class's constructor look like this: PHP_METHOD(test_class, __construct) { zval *tmp = NULL; ALLOC_ZVAL(tmp); tmp->is_ref = 0; tmp->refcount = 0; array_init(tmp); add_next_index_long(tmp, 100); zend_update_property(test_class_ce_ptr, this_ptr, "test_property", sizeof("test_property")-1, tmp TSRMLS_CC); } Then this PHP program: $e = new test_class(); print new ReflectionClass($e); var_dump($e); Prints: Class [ class test_class ] { - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [1] { Property [ public $test_property ] } - Methods [1] { Method [ public method __construct ] { } } } object(test_class)#1 (1) { ["test_property"]=> array(1) { [0]=> int(100) } } So it would be handy (since all the property creation would be in one place and there wouldn't be the confusing inference from reading the code that the property is NULL) if I could create the array zval in MINIT instead of in the constructor. David Marcus Boerger wrote: > Hello David, > > i did most of these functions but have no idea how to create default > arrays. If you find out please tell us. > > marcus > > Thursday, May 13, 2004, 9:29:02 PM, you wrote: > > >>zend_declare_property() tells me that I can't use it to create a class >>property that is an array. Why is that? What is the recommended way to >>create an array class property? > > >>Thanks, >>David > > > > >