RE: [PHP] evaluating a variable

This is a discussion on RE: [PHP] evaluating a variable within the PHP General forums, part of the PHP Programming Forums category; Eval ($contentfunction); gave me a parse error: Parse error: parse error in /home/pickled/public_html/main/inc/html.php(145) : ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-22-2003
Carey Baird
 
Posts: n/a
Default RE: [PHP] evaluating a variable


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:brad@robinsontech.com]
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

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:20 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0