Chris--
On my system, the function works as expected (at least as I understand
it): myFunc receives the parameters "Hello!" and array("this"=>"that"),
which is what you pass to it in the first place. Were you expecting it
to expand $myArrayVar into individual parameters? If so, that's not how
it works--it expands the values of the array you pass to it (which, in
this case, you build explicitly during the call), but doesn't expand any
arrays that may be within that array.
Also, call_user_method_array is now deprecated--you should use
call_user_func_array instead (the manual page for call_user_method_array
explains how to do this with a class method).
Cheers,
Marco
--
----------------
php|architect - The Monthly Magazine for PHP Professionals
Come check us out on the web at http://www.phparch.com!
--- Begin Message ---
How does this function really work? I've been
beating my head against the wall for the last
8 hours trying to figure it out. This is what
I'm trying and it isn't working:
{this is a very simplified version}
class MyClass {
function myFunc( $stringVar, $arrayVar ) {
echo "$stringVar<br>\n";
echo "<pre>\n";
print_r( $arrayVar );
echo "</pre>\n";
}
}
$myClass = new MyClass();
$myStringVar = "Hello!";
$myArrayVar = array( "this" => "that" );
call_user_method_array( 'myFunc',
&$myClass,
array( $myStringVar, $myArrayVar ));
What's happening is that the values in the array
are not being passed individually but instead is
being passed as an array. Shouldn't it be passing
them individually? If not, it wouldn't seem as if
you could use this function generically. You'd have
to specificy write your method so it can (possibly)
be called by this function. And that just doesn't
seem right.
Any light anyone can shed on this would be very much
appreciated!!
Chris
--- End Message ---
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php