Forum Moderators: coopster

Message Too Old, No Replies

Invoking a function on behalf of a user.

         

aspr1n

4:45 pm on May 13, 2003 (gmt 0)

10+ Year Member



I've got 30+ functions that can be initiated by and perform requests for a remote user, anyone got a good way of invoking a php functions without constantly checking for loads of $_GET variables?

I saw 'call_user_func' in the manual, and wondered if that might be an answer?

Cheers,

asp

lorax

4:52 pm on May 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Are we talking along the lines of RPC, SOAP, and WDDX?

aspr1n

6:22 pm on May 13, 2003 (gmt 0)

10+ Year Member



...had to go away and check to be sure ;)

No nothing as advanced as that. My problem is a little more convoluted than the example below but:

Say a user has "produced" a subset of data.

They may want to:

a) Query it further
b) Spell check it
c) Search and replace
d) Flag it for later use
e) Export it
d) Merge it with another record
e) Compare it against another record
etc etc...

Only I have about 30 of these individual functions to somehow attach to my UI. I'd prefer not to keep doing somekind of switch or ifelse statement through a load of potential $_GET variables.

One solution I had thought of was I set one $_POST value with the function name and its arguments seperated by ',' thus:

if ( isset( $_POST["DoFunc"] )) { 
list( $func, $args ) = explode( ",", $_POST["DoFunc"] );
call_user_func( $func, $args );
}

But this was me just kind thinking laterally and wondered if anyone else has solved this problem in a sweeter way.

asp