note 50117 deleted from function.call-user-func by danbrown
| From: | danbrown@php.net | Date: | Sat, 19 Jul 2008 21:10:40 +0000 |
| Subject: | note 50117 deleted from function.call-user-func by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-141745@lists.php.net to get a copy of this message | ||
Note Submitter: rob at PLEASEDONT dot digital-crocus dot SPAMME dot com
----
Hey
I'm struggling to think of a practical use for this function that can't be duplicated with
variable functions. The only use I can think of is when calling variable functions when your
variable need modification:
<?php
function hey1 { echo "hey1"; }
function hey2 { echo "hey2"; }
function hey3 { echo "hey3"; }
for ($n = 1; $n <= 3; $n++) {
// variable variables:
$func = "hey$n";
$$func();
// call_user_func():
call_user_func("hey$n");
}
?>
call_user_func() is one less line, however I would always use variable variables for readability.
Are there any more practical uses I'm overlooking?