Eval ($contentfunction); gave me a parse error:

Parse error: parse error in /home/pickled/public_html/main/inc/html.php(145)
: eval()'d code on line 1


$$contentfunction didn’t output anything

Any other ideas?

-----Original Message-----
From: Brad Pauly [mailto:[EMAIL PROTECTED] 
Sent: 22 December 2003 19:43
To: Carey Baird
Cc: php-gen
Subject: Re: [PHP] evaluating a variable

On Mon, 2003-12-22 at 12:36, 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()”;
>  
> //pass variable to another function
> Html_content($contentfunction);
>  
> //function is:
> function html_content($contentfunction)
> {
> ?>
>                                                 
>   <tr> 
>     <td colspan="2" valign="top">
>             <table width="100%" height="390" border="1" cellpadding="0"
> cellspacing="0" bordercolor="#666666" bgcolor="#FFFFFF">
>         <tr> 
>                         <td valign="top">
>                         <?
>                         $contentfunction; //doesn’t work
>                         Echo $contentfunction; //outputs the name of the
> function but does not evaluate it
>                         Echo “<? “.$contentfunction.” ?>”; //outputs <?
> Newsadmincontent() ?> but does not evaluate it
>                          ?>
>                          </td>
>         </tr>
>         </table>
>     </td>
>   </tr>
>                                                 
> <?
> }
>  
> 
> This does seem like a simple question but I cannot find any information to
> help me. Can anyone tell me how to get the function to be executed here?

Try $$contentfunction

- Brad

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.552 / Virus Database: 344 - Release Date: 15/12/2003
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.552 / Virus Database: 344 - Release Date: 15/12/2003
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to