RE: [PHP] Variable (naming them) Functions. DONE! DONE! DONE!

From: Date: Fri, 27 Apr 2001 18:22:17 +0000
Subject: RE: [PHP] Variable (naming them) Functions. DONE! DONE! DONE!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-50669@lists.php.net to get a copy of this message
Guys, I think LORD just looked down here in Tokyo, seen me still typing at 3.15am of Friday night, smoking the third pack of that nasty Marlboros, having no dinner, with no even a cup coffee remained... and sent to the list that GENIUS of Jason Murray who solved my problem. I know, Jason, you didn't mean it, but it REALLY helped me: $fname = 'hello'; $func = sprintf( "function %s(\$v='') { Return \"\$v<BR>\"; }", $fname ); eval($func); echo $fname('Please print it.... please....'); // And it did! a dynamic function! I got it. with eval() I can call it as I wish! I have no idea, HOW ON THE EARTH could I ever forget about magic EVAL(). I solved it! Everyone, take a note of this code, as it causes some sleepless nights and 'unhappy' girlfriends to some people. :-) Thanks everybody, Jason and Oliver in particular! Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) maxim@phpbeginner.com www.phpbeginner.com -----Original Message----- From: Christian Reiniger [mailto:creinig@mayn.de] Sent: Saturday, April 28, 2001 2:48 AM To: php-general@lists.php.net Subject: Re: [PHP] Variable (naming them) Functions. On Friday 27 April 2001 17:08, PHPBeginner.com wrote: > no classes CAN'T solve my problem: > > it is an abstraction layer. called as func_hello(); I want, inside > func_hello() {} declare a new function based on what happened before > func_hello() was called. In other words: I of course though about > classes, and there is in fact a work around, but I need to know if > 'function $var($arg) { return; }' syntax exists and what it is. > > in the docs there's nothing being said. http://php.net/create_function (maybe together with a little wrapper: $foo = create_function (...); $FNames [$var] = $foo; function delta ($FuncName, $args) { return ${$FNames[$FuncName]} ($args); } ) But such a thing is an ugly hack and I'm sure you don't need it. -- Christian Reiniger LGDC Webmaster (http://sunsite.dk/lgdc/) Error 032: Recursion error - see error 032 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#50669) next »