[wp-hackers] Using eval within Wordpress for a function mixed with html

Otto otto at ottodestruct.com
Tue Dec 2 14:35:50 GMT 2008


Yeah, I gotta agree with Alan on this one. If you're reading a text
file and then eval()ing it, then that's basically the same as an
include.

Now, on the other hand, if you're eval()ing because you want the
output back as a string, then the short answer is that you can't do
that. eval() executes the code, and if that code makes output, then it
makes the output. The returned result of the eval() call will be
whatever that code in the string does as it's "return" statement.
Output != returned data.

You'd have to use an output buffer to grab the output from the eval().
ob_start() and such.



On Mon, Dec 1, 2008 at 9:44 PM, Alan Castonguay <alan at verselogic.net> wrote:
> If you're just going to echo the result in the template, why not just
> include() the text file?


More information about the wp-hackers mailing list