At 19:15 20.11.2002, ROBERT MCPEAK said:
--------------------[snip]--------------------
>I've got a variable - $email_body, that contain's other variables.  For 
>example, echo "$email_body," might look like this:
>
>$name, $address, $phone, $blah
>
>
>I want those variables to interpreted with corresponding values set earlier 
>in the script.  So, in effect, where name=bob, address=101 east main, 
>phone=555-5555, and blah=foo, echo "$email_body" would look like this:
>
>bob, 101 east main, 555-5555, foo
--------------------[snip]-------------------- 

That's what eval() is for. eval() evaluates syntactically correct PHP code.

What you need to do is

    $email_body = str_replace('"', '\"', $email_body);
    global $php_error;
    $php_error = null;
    @eval("\$email_body = \"$email_body\";");
    if ($php_error) die ($php_error);

Of course all double quotes need to be escaped beforehand, as the example
shows. The error handling here is somewhat useless but demonstrates the idea.


-- 
   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035
    ^     http://www.vogelsinger.at/



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

Reply via email to