Passing Parameters By Reference to Callback Function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mikeym
Forum Newbie
Posts: 20
Joined: Sun Dec 16, 2007 8:07 am

Passing Parameters By Reference to Callback Function

Post by mikeym »

Hi,

Is it possible to pass a parameter by reference to a callback function?

PS I'm using PHP 4.4.2
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Passing Parameters By Reference to Callback Function

Post by John Cartwright »

How are you applying the callback?

Code: Select all

call_user_func_array('function', array(&$foobar));
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Re: Passing Parameters By Reference to Callback Function

Post by Ambush Commander »

Use Jcart's syntax. If the function def has the ref, but not the callback, the variable is not passed by reference.
mikeym
Forum Newbie
Posts: 20
Joined: Sun Dec 16, 2007 8:07 am

Re: Passing Parameters By Reference to Callback Function

Post by mikeym »

Thanks that worked.
Post Reply