Re: eval function

From: Date: Sat, 23 Aug 2003 17:04:26 +0000
Subject: Re: eval function
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-160511@lists.php.net to get a copy of this message
Hallo Tom, am Samstag, 23. August 2003 um 17:50 hast Du Folgendes gekritzelt: TR> Hi, TR> Saturday, August 23, 2003, 10:01:54 PM, you wrote: MW>> Hallo Tom, MW>> am Samstag, 23. August 2003 um 05:14 hast Du Folgendes gekritzelt: TR>>> This should do it: TR>>> eval('${"content".$databasepagename}[$i]();'); MW>> I'm afraid to say it, but it does not :-( MW>> Yesterday I was also trying to find some manual pages about eval() MW>> which would explain me the syntax. The example in the PHP-Manual is MW>> not meaning much to me. MW>> How can I print out what eval would evaluate, so I can see how to MW>> compose the string? MW>> Thx for answering again ;-) MW>> SvT TR> This works for me, what error message do you get? Make sure you use TR> single quotes in the eval otherwise the string will get substituted TR> before eval gets a look at it. TR> <?php TR> $contentarray = array(1=>'testpage'); TR> function testpage(){ TR> echo 'Test succceeded <br>'; TR> } TR> $i = 1; TR> $databasepagename = 'array'; TR> eval('${"content".$databasepagename}[$i]();'); ?>> Sorry, I got it to show errors... here: (it's almost the same than in apache-log) Notice: Undefined variable: contentArray in /usr/local/www/showFunctions.php(77) : eval()'d code on line 1 Fatal error: Call to undefined function: () in /usr/local/www/showFunctions.php(77) : eval()'d code on line 1 SvT -- Who is the ennemy? mailto:elektrik@gmx.net

« previous php.general (#160511) next »