At 19:15 20.11.2002, ROBERT MCPEAK said:
>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

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

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to