FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Using PHP Tags in eval()
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Using PHP Tags in eval() [message #175716] Sat, 22 October 2011 16:15 Go to next message
Luke23ae is currently offline  Luke23ae
Messages: 2
Registered: October 2011
Karma: 0
Junior Member
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,
Lukas
Re: Using PHP Tags in eval() [message #175717 is a reply to message #175716] Sat, 22 October 2011 16:34 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article
<38899de6-5a2d-4eaa-b366-5d01b45f70e7(at)f36g2000vbm(dot)googlegroups(dot)com>,
Luke23ae <lukas(dot)bombach(at)googlemail(dot)com> wrote:

> 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?

Where are you doing the eval?

--
Tim

"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() [message #175783 is a reply to message #175717] Mon, 24 October 2011 07:34 Go to previous messageGo to next message
Luke23ae is currently offline  Luke23ae
Messages: 2
Registered: October 2011
Karma: 0
Junior Member
What do you mean by "where"? Not inside another function if that's what you're asking
Re: Using PHP Tags in eval() [message #175784 is a reply to message #175716] Mon, 24 October 2011 07:51 Go to previous messageGo to next message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
El 22/10/2011 18:15, Luke23ae escribió/wrote:
> 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?

Works for me:

<?php

$_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


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
Re: Using PHP Tags in eval() [message #175785 is a reply to message #175716] Mon, 24 October 2011 08:30 Go to previous message
Willem Bogaerts is currently offline  Willem Bogaerts
Messages: 8
Registered: September 2010
Karma: 0
Junior Member
> 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']);

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.
http://www.kratz.nl/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: getting a url with a mS timout in PHP < 5.2
Next Topic: execute php in template
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 19:37:06 GMT 2024

Total time taken to generate the page: 0.02831 seconds