>-----Ursprüngliche Nachricht-----
>Von: Robert S. White [mailto:[EMAIL PROTECTED]]
>Gesendet: Mittwoch, 24. Januar 2001 16:20
>An: [EMAIL PROTECTED]
>Betreff: Re: [PHP] eval() to string???
>
>
>How is this going to help me?
>
>I want to evaluate the code in $php_code to *another* string...
>
From
http://www.php.net/manual/en/function.eval.php :
"A return statement will terminate the evaluation of the string
immediatley. In PHP 4 you may use return to return a value that will
become the result of the eval() function while in PHP 3 eval() was of
type void and did never return anything."
So, if you're using PHP4, just ensure that there is a return
in$php_code that returns the desired value:
$thing = eval($php_code);
It's helpful to read the notes at the above URL - escaping things
correctly for eval() can be tricky...
- steve
>----- Original Message -----
>From: Thomas Weber <>
>To: Php-General <>
>Sent: Wednesday, January 24, 2001 10:14 AM
>Subject: AW: [PHP] eval() to string???
>
>
>> try
>>
>> eval("\$php_code;");
>>
>> -----Ursprüngliche Nachricht-----
>> Von: [ rswfire ] [mailto:[EMAIL PROTECTED]]
>> Gesendet: Mittwoch, 24. Januar 2001 15:36
>> An: [EMAIL PROTECTED]
>> Betreff: [PHP] eval() to string???
>>
>>
>> I want to evaluate some PHP code to a string. How can I do this?
>>
>> $php_code = "echo 'hello';"
>>
>> I would like to evaluate the code to "hello" in another string...
>>
>>
> > --
--
+--- "They've got a cherry pie there, that'll kill ya" ------------------+
| Steve Edberg University of California, Davis |
| [EMAIL PROTECTED] Computer Consultant |
| http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ |
+-------------------------------------- FBI Special Agent Dale Cooper ---+
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]