note 97897 deleted from function.call-user-func by danbrown

From: Date: Fri, 14 May 2010 15:05:09 +0000
Subject: note 97897 deleted from function.call-user-func by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-169255@lists.php.net to get a copy of this message
Note Submitter: pablobm at gmail dot com ---- Further to Maxdamantus's comment, this is another example of what works and what doesn't when some of the parameters are expected to be passed by reference: <?php $alphabet = array( 'a' => 'alpha', 'b' => 'beta', ); function add_letter(&$a, $roman, $greek_name) { $a[$roman] = $greek_name; } // Gives warning and doesn't work call_user_func('add_letter', $alphabet, 'c', 'gamma'); print_r($alphabet); // Works call_user_func('add_letter', &$alphabet, 'd', 'delta'); print_r($alphabet); // Works $func_name = 'add_letter'; $func_name($alphabet, 'e', 'epsilon'); print_r($alphabet); ?>

« previous php.notes (#169255) next »