Re[2]: [PHP] eval function
| From: | Tom Rogers | Date: | Sat, 23 Aug 2003 15:50:47 +0000 |
| Subject: | Re[2]: [PHP] eval function | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-160508@lists.php.net to get a copy of this message | ||
Hi,
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
This works for me, what error message do you get? Make sure you use
single quotes in the eval otherwise the string will get substituted
before eval gets a look at it.
<?php
$contentarray = array(1=>'testpage');
function testpage(){
echo 'Test succceeded <br>';
}
$i = 1;
$databasepagename = 'array';
eval('${"content".$databasepagename}[$i]();');
?>
--
regards,
Tom