Using PHP Tags in eval()

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi there,

I have a textarea where you can write PHP & HTML (or technically
anything else). You can preview your Code in the browser by submitting
the form and what I wanna do is eval() the code (and thereby display)
it. Now eval doesn't seem to accept PHP-Tags (<?PHP ?>) in it the
given string. I've read many posts that suggest calling eval like

eval(' ?>'.$_POST['markup']);

But that my have worked once but it doesn't work anymore. I get a
Syntax error for the lines where there's a PHP-Tag.

Is there a way to still eval Strings that contain PHP-Tags?

Thank you,

Re: Using PHP Tags in eval()

In article

Quoted text here. Click to load it

Where are you doing the eval?


"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689

Re: Using PHP Tags in eval()

What do you mean by "where"? Not inside another function if that's what you're

Re: Using PHP Tags in eval()

El 22/10/2011 18:15, Luke23ae escribió/wrote:
Quoted text here. Click to load it

Works for me:


    $_POST['markup'] = 'Lorem ipsum dolor sit amet' . PHP_EOL;

    // First time
    eval(' ?>'.$_POST['markup']);

    // Second time
    eval(' ?>'.$_POST['markup']);

... prints this:

    Lorem ipsum dolor sit amet
    Lorem ipsum dolor sit amet

-- - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:
-- Mi web de humor satinado:

Re: Using PHP Tags in eval()

Quoted text here. Click to load it

You are aware that you are giving an awful lot of control over your
server away to the first hacker that comes around? I would never do that
on a live server and not even in a private network.

Best regards,
Willem Bogaerts

Application smith
Kratz B.V. /

Site Timeline