Thank you for the example. Is working.
I was figure out what was the problem:
INIT_CLASS_ENTRY(rt66class_class_entry,
"RT66Class", /* here */
php_rt66class_class_functions);
writing "RT66Class" do not work, but writing "rt66class" is working!!!
Many thanks for your help,
Emanuel Dejanu
Writing an PHP extension is a real adventure.
P.S. I also write very pour english so sorry for my mistakes.
> -----Original Message-----
> From: Hansuck Jo [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 26, 2001 1:04 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP-DEV] RE: Re: How do I register a
> constructor in PHP (C code)
>
>
> Hm.. attachement file is my full source..
>
> To compile:
> tar xzf scl.tgz
> mv scl any_path/php-4.0.6/ext
> cd php-4.0.6
> rm configure config.cache
> ./buildconf
> ./confgure --with-scl
> make
>
>
> To Test:
> ./php -q ext/scl/scl.php
>
>
> Testing Results:
> Object Created.
> Subojbect Created.
>
>
> PS. I can't speak English... ^^;;
> but I can readonly English... (You understand?? ^^;;)
>
> PS. I have 64M DRAM cylix 166MHz.. TT
> PHP 4.0.6, Wow-Linux 7.1 (Redhat 7.1 compat...)
> No Apache.. (I compile CGI mode)
>
>
> Emanuel Dejanu wrote:
>
> >tr(/PHP_/ZEND_/)
> >and still do not work. I have compared your example with my
> >code and no difference found on it.
> >
> >Have you any other suggestions.
> >
> >I really need the constructor and I can not do it.
> >
> >Best regards,
> >
> >Emanuel Dejanu
> >
> >P.S. I run Apache 1.3.20 PHP 4.0.6 Linux 2.2.18-SMP SuSE 7.1
> >on Dual Pentium III 800 MHz (712 MB RAM) machine.
> >
> >>-----Original Message-----
> >>From: Hansuck Jo [mailto:[EMAIL PROTECTED]]
> >>Sent: Wednesday, September 26, 2001 11:02 AM
> >>To: [EMAIL PROTECTED]
> >>Subject: Re: [PHP-DEV] RE: Re: How do I register a
> >>constructor in PHP (C code)
> >>
> >>
> >>hm... ZEND_* functions instead PHP_* functions.
> >>
> >>This is sample code..(of course. You must include zend.h etc..)
> >>
> >>
> >>
> >>static zend_function_entry scl_functions[] = {
> >> {NULL, NULL, NULL}
> >>};
> >>
> >>zend_module_entry scl_module_entry = {
> >> "scl",
> >> scl_functions,
> >> ZEND_MINIT(scl),
> >> NULL,
> >> NULL,
> >> NULL,
> >> ZEND_MINFO(scl),
> >> STANDARD_MODULE_PROPERTIES
> >>};
> >>
> >>
> >>zend_class_entry scl_object_class_entry;
> >>zend_function_entry scl_object_functions[] = {
> >> ZEND_FALIAS(object, object_init, NULL)
> >> {NULL, NULL, NULL}
> >>};
> >>
> >>
> >>ZEND_FUNCTION(object_init)
> >>{
> >> zval *obj;
> >>
> >> obj = getThis();
> >>
> >> if (obj) {
> >> if (ZEND_NUM_ARGS() != 0) {
> >> ZEND_WRONG_PARAM_COUNT();
> >> }
> >> zend_printf("Object Create.");
> >>
> >> RETURN_TRUE;
> >> }
> >> else {
> >> zend_error(E_WARNING, "This can't excute in
> >>Class Method");
> >> RETURN_FALSE;
> >> }
> >>}
> >>
> >>ZEND_MINIT_FUNCTION(scl)
> >>{
> >>
> >> INIT_CLASS_ENTRY(scl_object_class_entry, "object",
> >> scl_object_functions);
> >> zend_register_internal_class(&scl_object_class_entry);
> >>}
> >>
> >>
> >>Emanuel Dejanu wrote:
> >>
> >>>I have write using the init but still do not work.
> >>>
> >>>Any other ideea.
> >>>
> >>>Best regards,
> >>>
> >>>Emanuel Dejanu
> >>>
> >>>
> >>>
> >>>>-----Original Message-----
> >>>>From: Hansuck Jo [mailto:""sizer"@.php.net]
> >>>>Sent: Tuesday, September 25, 2001 6:31 PM
> >>>>To: [EMAIL PROTECTED]
> >>>>Subject: [PHP-DEV] Re: How do I register a constructor in
> >>>>
> >>PHP (C code)
> >>
> >>>>
> >>>>You use rt66clsss_init() instead of rt66class_contstructor().
> >>>>may be, it's will work. :)
> >>>>
> >>>>
> >>>>Emanuel Dejanu wrote:
> >>>>
> >>>>
> >>>>>I write an extension and I want to register a new class
> >>>>>but I can not get my function to be registered as a constructor.
> >>>>>
> >>>>>ex:
> >>>>>PHP_FUNCTION(rt66class_constructor);
> >>>>>static zend_function_entry php_rt66class_class_functions[] =
> >>>>>{
> >>>>> PHP_FALIAS(RT66Class, rt66class_constructor, NULL)
> >>>>>};
> >>>>>
> >>>>>PHP_MINIT_FUNCTION(rt66util)
> >>>>>{
> >>>>> zend_class_entry rt66class_class_entry;
> >>>>> INIT_CLASS_ENTRY(rt66class_class_entry, "RT66Class",
> >>>>>php_rt66class_class_functions);
> >>>>> RT66Class_class_entry_ptr =
> >>>>>zend_register_internal_class(&rt66class_class_entry);
> >>>>>
> >>>>> return SUCCESS;
> >>>>>}
> >>>>>
> >>>>>PHP_FUNCTION(rt66class_constructor)
> >>>>>{
> >>>>> ZEND_PUTS("RT66Class Contructor");
> >>>>>}
> >>>>>
> >>>>>
> >>>>>-----
> >>>>><?php
> >>>>> dl(myext.so);
> >>>>> $myvar = RT66Class();
> >>>>>?>
> >>>>>
> >>>>>nothing appear on the screen.
> >>>>>
> >>>>>Please tell me how can I make it to work.
> >>>>>
> >>>>>Many thanks,
> >>>>>
> >>>>>Emanuel Dejanu
> >>>>>
> >>>>>
> >>>>>
> >>>>>>-----Original Message-----
> >>>>>>From: Andy [mailto:[EMAIL PROTECTED]]
> >>>>>>Sent: Wednesday, August 01, 2001 3:27 PM
> >>>>>>To: [EMAIL PROTECTED]
> >>>>>>Subject: Fwd: FW: [PHP-DEV] print_r
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>---------- Forwarded Message ----------
> >>>>>>Subject: FW: [PHP-DEV] print_r
> >>>>>>Date: Wed, 1 Aug 2001 08:19:09 +0300
> >>>>>>From: "Emanuel Dejanu" <[EMAIL PROTECTED]>
> >>>>>>
> >>>>>>
> >>>>>>Sorry to forward this to you but I really have problems in
> >>>>>>printing a doubled linked class.
> >>>>>>Can you take a look at the following message and give me
> >>>>>>an answer.
> >>>>>>
> >>>>>>Thanks,
> >>>>>>
> >>>>>>Emanuel Dejanu
> >>>>>>
> >>>>>>-----Original Message-----
> >>>>>>From: Emanuel Dejanu [mailto:[EMAIL PROTECTED]]
> >>>>>>Sent: Tuesday, July 31, 2001 9:22 AM
> >>>>>>To: [EMAIL PROTECTED]
> >>>>>>Subject: [PHP-DEV] print_r
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>Hi,
> >>>>>>
> >>>>>>Is there a posibility to print an object but to not print
> >>>>>>
> >>>>some fields.
> >>>>
> >>>>>>If I use print_r he will print all variabiles from my object,
> >>>>>>but I want on
> >>>>>>variabile to not be printed. I do not want to write my
> >>>>>>
> >>own function.
> >>
> >>>>>>Ex.
> >>>>>>
> >>>>>>class Node {
> >>>>>> var $name;
> >>>>>> var $parent = '/'
> >>>>>> var $children = array();
> >>>>>> function Node($name, &$parent) {
> >>>>>> $this->parent = &$parent;
> >>>>>> $this->name = $name;
> >>>>>> }
> >>>>>>}
> >>>>>>
> >>>>>>$rootNode = new Node('root', '');
> >>>>>>array_push($rootNode->children, new Node('child1', $rootNode));
> >>>>>>$child1Node = &$rootNode->children[0];
> >>>>>>array_push($child1Node->children, new Node('child1',
> >>>>>>
> >>$child1Node));
> >>
> >>>>>>print_r($rootNode);
> >>>>>>
> >>>>>>will print make a recursivity. What will be nice is to
> >>>>>>
> >>>>allow that some
> >>>>
> >>>>>>variabiles to not
> >>>>>>be printed like this:
> >>>>>>
> >>>>>>class Node {
> >>>>>> var $name;
> >>>>>> var $__parent = '/'
> >>>>>> var $children = array();
> >>>>>> function Node($name, &$parent) {
> >>>>>> $this->__parent = &$parent;
> >>>>>> $this->name = $name;
> >>>>>> }
> >>>>>>}
> >>>>>>
> >>>>>>..... /* add the root and childrens */
> >>>>>>
> >>>>>>print_r($rootNode);
> >>>>>>
> >>>>>>will print now the corret tree.
> >>>>>>
> >>>>>>Bellow you find the only modification that need to be done
> >>>>>>for this to work.
> >>>>>>
> >>>>>>Best regards,
> >>>>>>
> >>>>>>Emanuel Dejanu
> >>>>>>
> >>>>>>
> >>>>>>File: Zend/zend.c
> >>>>>>
> >>>>>>static void print_hash(HashTable *ht, int indent)
> >>>>>>{
> >>>>>> zval **tmp;
> >>>>>> char *string_key;
> >>>>>> HashPosition iterator;
> >>>>>> unsigned long num_key, str_len;
> >>>>>> int i, key_type; /****** HERE *****/
> >>>>>>
> >>>>>> for (i=0; i<indent; i++) {
> >>>>>> ZEND_PUTS(" ");
> >>>>>> }
> >>>>>> ZEND_PUTS("(\n");
> >>>>>> indent += PRINT_ZVAL_INDENT;
> >>>>>> zend_hash_internal_pointer_reset_ex(ht, &iterator);
> >>>>>> while (zend_hash_get_current_data_ex(ht, (void **)
> >>>>>>&tmp, &iterator) ==
> >>>>>>SUCCESS) {
> >>>>>>
> >>>>>>
> >>>>>>/******** HERE **************/
> >>>>>>
> >>>>>> key_type = zend_hash_get_current_key_ex(ht,
> >>>>>>&string_key, &str_len,
> >>>>>>&num_key, 0, &iterator);
> >>>>>> if (key_type == HASH_KEY_IS_STRING)
> >>>>>> if (string_key[0] == '_' &&
> >>>>>>string_key[1] == '_') continue;
> >>>>>>
> >>>>>>
> >>>>>>/******* HERE **************/
> >>>>>>
> >>>>>>
> >>>>>> for (i=0; i<indent; i++) {
> >>>>>> ZEND_PUTS(" ");
> >>>>>> }
> >>>>>> ZEND_PUTS("[");
> >>>>>> switch (key_type) {
> >>>>>> case HASH_KEY_IS_STRING:
> >>>>>> ZEND_PUTS(string_key);
> >>>>>> break;
> >>>>>> case HASH_KEY_IS_LONG:
> >>>>>> zend_printf("%ld",num_key);
> >>>>>> break;
> >>>>>> }
> >>>>>> ZEND_PUTS("] => ");
> >>>>>> zend_print_zval_r(*tmp,
> indent+PRINT_ZVAL_INDENT);
> >>>>>> ZEND_PUTS("\n");
> >>>>>> zend_hash_move_forward_ex(ht, &iterator);
> >>>>>> }
> >>>>>> indent -= PRINT_ZVAL_INDENT;
> >>>>>> for (i=0; i<indent; i++) {
> >>>>>> ZEND_PUTS(" ");
> >>>>>> }
> >>>>>> ZEND_PUTS(")\n");
> >>>>>>}
> >>>>>>
> >>>>>>
> >>>>>>--
> >>>>>>PHP Development Mailing List <http://www.php.net/>
> >>>>>>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>>>>>For additional commands, e-mail: [EMAIL PROTECTED]
> >>>>>>To contact the list administrators, e-mail:
> >>>>>>[EMAIL PROTECTED]
> >>>>>>-------------------------------------------------------
> >>>>>>
> >>>>>>--
> >>>>>>PHP Development Mailing List <http://www.php.net/>
> >>>>>>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>>>>>For additional commands, e-mail: [EMAIL PROTECTED]
> >>>>>>To contact the list administrators, e-mail:
> >>>>>>[EMAIL PROTECTED]
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>
> >>>>--
> >>>>PHP Development Mailing List <http://www.php.net/>
> >>>>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>>>For additional commands, e-mail: [EMAIL PROTECTED]
> >>>>To contact the list administrators, e-mail:
> >>>>[EMAIL PROTECTED]
> >>>>
> >>>>
> >>
> >>
> >>--
> >>PHP Development Mailing List <http://www.php.net/>
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>To contact the list administrators, e-mail:
> >>[EMAIL PROTECTED]
> >>
>
>
>
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]