Re: Re: Using XML_RPC with object oriented code

From: Date: Wed, 11 Feb 2004 14:30:57 +0000
Subject: Re: Re: Using XML_RPC with object oriented code
References: 1 2 3 4  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-10629@lists.php.net to get a copy of this message
What about somehow passing the function by reference? I tested it using PHP5 (which is what i'm writing for), and it seemed to work. It may take some butchering of the XML_RPC Server code. This seems to be much cleaner than passing the function name as a string. Think it's feasible? I'll give it a shot soon. Thanks, Norman ------------------------------------------------------ Norman Elton Information Technology - Network Engineering College of William & Mary 757-221-7790 On Feb 10, 2004, at 11:01 AM, Sergio Carvalho wrote:
True. This does require the use of a static function. You can, however, work around the problem. If the request is dispatched by a Singleton, as is usual, you just have to do something like: class Foo { function bar() { if (!isset($this)) {
     $obj = Foo::getSingleton();
     return $obj->bar();
} (rest of bar) } } If the request is served by an arbitrary instance, use function static variables (this is way uglier): class Foo { function realBar(...) { (...) } function bar(..., $fooInstance = null) { static $foo = null; if (!isnull(fooInstance)) {
     $foo = $fooInstance;
} else {
     $foo->bar(...);
} } } Foo::bar must be called with $fooInstance set before it can service any request. Cheers, Sérgio Norman Elton wrote:
Wouldn't this require that it be a static function? How could I access the member variables of the object instance? Norman
-- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.pear.general (#10629) next »