callback problem

From: Date: Thu, 15 Feb 2001 13:16:56 +0000
Subject: callback problem
Groups: php.pear 
Request: Send a blank email to php-pear+get-1352@lists.php.net to get a copy of this message
Hello, I am trying to build up a class with some sort of a callback mechanism. A simplified code is given below: <?php class provider { function myfunction() { echo "burak"; } } class dispatcher { function process($p1,$p2,$p3) { call_user_method($p1,$$p2,$p3); } } $x= new provider(); $y= new dispatcher(); $y->process("returnI","x",""); ?> I am expecting to be able to call a method of the "provider" by giving a reference to it as a string or whatever. However the script above does not run. My goal is to build a form-validator class, which gets some field definitions and validation function pointers. It will attempt to validate each field by calling the associated function. It will return OK if all the validators are ok and ERROR when at least one validation has failed. The issue is, the validation functions might either be methods of a class instance or seperate functions. Anyone has any idea to make such a callback work? regards, -bd

« previous php.pear (#1352) next »