How to add methods to one object ?

From: Date: Thu, 18 May 2000 11:17:28 +0000
Subject: How to add methods to one object ?
Groups: php.version4 
Request: Send a blank email to php-version4+get-15181@lists.php.net to get a copy of this message
Hi, I would like to known the best way to overload object method. I use tow solutions: 1) ---------------------- INIT_CLASS_ENTRY(MyClass_class_entry, "MyClass", php_MyClass_class_functions ); static zend_function_entry new_methods_for_MyClass[] = { PHP_FALIAS(method_one, MyClass_call_function_handler , NULL) PHP_FALIAS(method_two, MyClass_call_function_handler, NULL) {NULL, NULL, NULL} }; Add_methods() { zend_register_functions(new_methods_for_MyClass, &(MyClass_class_entry_ptr->function_table)); } void MyClass_call_function_handler (INTERNAL_FUNCTION_PARAMETERS) { ... ... } 2) ---------------------- INIT_OVERLOADED_CLASS_ENTRY(MyClass_class_entry, "MyClass", php_MyClass_class_functions , MyClass_call_function_handler , MyClass_get_property_handler , MyClass_set_property_handler ); --------------------------- In the first case, I can use methods in php_MyClass_class_functions and in new_methods_for_MyClass but the function MyClass_call_function_handler don't known the method name. In the second case, if I use a method of the php_MyClass_class_functions list, the appropriate method is not call because MyClass_call_function_handler is used. ---------------------------- My question is : What is the best solution to add some methods at the runtime ??? Thanks. Jeremie.

« previous php.version4 (#15181) next »