Re: evaluating a variable

From: Date: Mon, 22 Dec 2003 20:09:43 +0000
Subject: Re: evaluating a variable
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-173195@lists.php.net to get a copy of this message
Carey Baird wrote:
Hey, I have stored the name of a function as a variable. I have then passed the variable to another function as follows: //put function name in a variable $contentfunction = “newsadmincontent()”;
Take off the parenthesis... $contentfunction = 'newsadmincontent'; To call the function, you simply use: $contentfunction(); Which will call the "newsadmincontent" function. $contentfunction = 'newsadmincontent'; html_function($contentfunction); function html_function($func_name) { echo "You requested to execute the function: $func_name."; echo 'The output of the function is: ' . $func_name(); } -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com

« previous php.general (#173195) next »