PDA

View Full Version : eval();


Sparkz
05-13-2002, 11:49 AM
I have a variable

$myvar = "http://my.host.com/script.php?var=$content['var']&var2=$content['somethingelse']";


Now, I want to use eval() to evaluate the contents of $myvar into another var, something like

eval ("$url = \"$myvar\";");


This gives me errors, tho...

Parse error: parse error in /usr/local/web/modules/mod_http.inc(7) : eval()'d code on line 1


can anyone help me with this one?

Admin
05-13-2002, 11:51 AM
$myvar = 'http://my.host.com/script.php?var=$content[var]&var2=$content[somethingelse]';
eval ("\$url = \"$myvar\";");

Sparkz
05-13-2002, 01:09 PM
Thx.
I wish I could get it working referencing array elements like $var['lala'] instead of just $var[lala] (which is deprecated)

Since this is code that will leave my hands and end up at a fair few of our customers servers, I'd preffer to do it 'right' first time off...

Admin
05-13-2002, 04:44 PM
Don't worry about using $array[index] inside strings, it's not deprecated. It's only when you are using the variables as "stand alone", i.e $array['index'] == 'foo'.

Sparkz
05-13-2002, 05:06 PM
m'kay :)
Thanx again :)