Hallo Tom,
am Samstag, 23. August 2003 um 17:50 hast Du Folgendes gekritzelt:
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]();');
?>>
That's the error I find in the apache-log. On the screen, I get
nothing but a white page. By the way I have error_reporting(E_ALL);
but I never get errors reported...
PHP Fatal error: Call to undefined function: () in
/usr/local/www/showFunctions.php(77)
Your script is working. But mine not... is it because I'm on a output
buffer? I use ob_start() just before, because the real output is
produced by the function I want to call with the eval method...
Here the part of my script:
$query = "SELECT pagename FROM pages";
$result = mysql_query($query);
$a = 0;
while($row = mysql_fetch_array($result, MYSQL_BOTH)){
$page[$a] = $row["pagename"];
$fct[$a] = $page[$a];
$fct[$a] = substr($fct[$a],1);
$fct[$a] = str_replace(".php", "", $fct[$a]);
$fct[$a] = ucfirst($fct[$a]);
$a++;
}
mysql_free_result($result);
ob_start();
for($b = 0; $b < sizeof($fct); $b++){
if($_SERVER["PHP_SELF"] == $page[$b])
eval('${"content".$fct}[$b]();');
}
...
The "pagename" in the database is stored like /about.php so I change
it to About in the while-loop.
The eval method is there to replace my actual code (which is static):
if($_SERVER["PHP_SELF"] == "/login.php")
contentLogin();
if($_SERVER["PHP_SELF"] == "/logout.php")
contentLogout();
...
Using the "if-cascade", it is working, for you to know that the
mistake is definitly in the eval()-method...
Thx for your time...
SvT
--
Who is the ennemy?
mailto:[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php