Re: eval() with CONSTANTS

From: Date: Fri, 21 May 2004 01:10:39 +0000
Subject: Re: eval() with CONSTANTS
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-186650@lists.php.net to get a copy of this message
Hi, Friday, May 21, 2004, 8:26:30 AM, you wrote: GD> How can I eval() an HTML template to make a CONSTANT be evaluated GD> properly? GD> Previously I have been using regular $variables in my HTML templates. GD> Today I decided to make one of the $variables a CONSTANT only to find it GD> would not parse out as it's defined value. It is instead treated as GD> regular text. I tried wrapping the CONSTANT with curly braces, and also GD> tried using the constant() function with it in the HTML template. GD> Neither return the value I previously defined with define(). The manual GD> says "Constants may be defined and accessed anywhere without regard to GD> variable scoping rules" but I'm missing something. GD> I do: GD> define('TABLE_PARAMETERS', ' border=0 cellspacing=0 cellpadding=0'); GD> Then I get and eval() my template: GD> $index = getTemplate('index'); GD> eval("\$index = \"$index\";"); GD> And I end up with HTML that looks like: GD> <table {TABLE_PARAMETERS}> GD> instead of the desired GD> <table border=0 cellspacing=0 cellpadding=0> GD> Any ideas? I've google'd, and read lots of docs today trying to figure GD> it out but I don't know what else to try. GD> TIA. GD> -- GD> Greg Donald GD> destiney@destiney.com There is no way for php to what is a constant and what is text so you have to put it in a variable to use it in a string. -- regards, Tom

« previous php.general (#186650) next »