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