Re: [PHP] Execution order of PHP

[email protected] (Bruno Fajardo)
Newsgroups php.general
Message-ID <[email protected]>
2010/3/10 Auke van Slooten <[email protected]>:
> Bruno Fajardo wrote:
>>
>> 2010/3/10 Auke van Slooten <[email protected]>
>>>
>>> Hi,
>>>
>>> In a hobby project I'm relying on the order in which the following piece
>>> of PHP code is executed:
>>>
>>> $client->system->multiCall(
>>>  $client->methodOne(),
>>>  $client->methodTwo()
>>> );
>>
>> Can't you call the methods $client->methodOne() and
>> $client->methodTwo() before the call to $client->system->multiCall()?
>> That way, you could store they values in local variables, and then
>> pass them to the $client->system->multiCall(), assuring that those
>> methods are executed before the multiCall(). Something like:
>>
>> $methodOne = $client->methodOne();
>> $methodTwo = $client->methodTwo();
>> $client->system->multiCall($methodOne, $methodTwo);
>
> Hi,
>
> This is not what I meant. I should perhaps mention that it's an xml-rpc
> client and the method calls are remote method calls. The multiCall method
> gathers multiple method calls into a single request.
>
> The trick I'm using now is to set a private property in the $client->__get()
> method when the property you're accessing is 'system'. From then untill you
> call the method 'multiCall', instead of calling the methods (in this case
> methodOne and methodTwo) the client creates a new object with the call
> information (method name and arguments) and returns that. In multiCall all
> arguments are therefor call information objects and multicall creates a
> single request based on that information.

Hmm, you cleared that to me now... If you need to first create the
property "system" and then call a method in that object "system",
can't you do something like:

$client->system = null;
$client->system->multiCall(
    $client->methodOne(),
    $client->methodTwo()
);

I'm not testing these snippets of code, so sorry if I'm getting something wrong.

Cheers,
Bruno.

>
> So in your example the client would simply call methodOne and methodTwo and
> return the results. Then it would try to do a multiCall with whatever the
> previous methods have returned.
>
> regards,
> Auke van Slooten
> Muze
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.