Variable (naming them) Functions.

From: Date: Fri, 27 Apr 2001 12:00:27 +0000
Subject: Variable (naming them) Functions.
Groups: php.general 
Request: Send a blank email to php-general+get-50598@lists.php.net to get a copy of this message
got a typo in my previous post: I was trying this: $fname = 'hello'; function { sprintf("%s", $fname) }($fname='') { Return "I named you : $fname"; } echo $fname($fname); But that doesn't matter... Thanks, waiting for your help. Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) maxim@phpbeginner.com www.phpbeginner.com -----Original Message----- From: Maxim Maletsky Sent: Friday, April 27, 2001 8:58 PM To: 'PHP General List. (E-mail)' Subject: [PHP] Variable (naming them) Functions. Hello everyone: I was wondering, does anyone of you know a method to declare a function (give it a name) basing on a value acquired during run time? I tried using the syntax as of a variable function call: <snip> $fname = 'hello'; function { sprintf("%s", $fname) }($arg='') { Return "I named you : $fname"; } echo $fname($fname); # no luck... function {$fname}($arg='') { .... # nope... function $fname($arg='') { .... # neither... </snip> and so on... all parse errors... Any way to do it? I am looping an array with some function names checking if a function was declared already, and if not then declare, if yes - give a different name. I also went through these bibles: http://www.php.net/manual/en/ref.funchand.php <http://www.php.net/manual/en/ref.funchand.php> but found nothing that helps. Thanks in advance, Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) maxim@phpbeginner.com <mailto:maxim@phpbeginner.com> www.phpbeginner.com <http://www.phpbeginner.com>

« previous php.general (#50598) next »