Re: Passing an indefinite number of parameters by reference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chris Jenkinson wrote:
Hi,

Currently I have a function which accepts a limited number of parameters:

call_function($function_name, &$var_1, &$var_2);

I wish to modify the function to accept an indefinite number of parameters, which may or may not be references.

The function call_function() then calls the function specified in $function_name, with the variables passed as parameters to that function.

Is this possible? Thanks for any help which can be offered.

I believe it is - BUT it won't be easy, also I think you can only really do this
properly in php5 using a shedload of reflection functionality:

http://php.net/manual/en/language.oop5.reflection.php

although I wonder whether you shouldn't be re-evaluating what it is
your trying to do because I get the impression it's a whole load of work
for probably little payoff (consider that using alot of indirection in your
code will make it harder to understand/read and therefore harder to debug/maintain).
why not consider the possibility that all these 'by reference' args could be items
in a single 'by reference' array?

btw: have you met call_user_func_array() yet? (not that it
would solve the problem because it doesn't 'do' references) - also,
it's manual page offers a hack for the reference problem your working on.


Chris


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux