splite and replace code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jim_php
Forum Newbie
Posts: 16
Joined: Sat Mar 22, 2008 6:16 am

splite and replace code

Post by jim_php »

hello i try to split and replace a mysql result

i have one form to store data and one field called description

in this textarea (description) i write
-----------------
hello all this is a text <code> ?> $4 = 2+2; echo "$4"; <?</code>
------------------

okay now i want to execute the code but ooooonly from <code> to </code>

to use as folowing

$description = $row->description; // hello all this is a text
and
$description = eval($row->description); // 4


echo $description;



any good idea ?

i thin something that

$description .= preg_replace("[<code>]", " "; echo eval( ", $row->description);
$description .= preg_replace("[</code>]", " ); ", $row->description);

echo $description;
but not working
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: splite and replace code

Post by jayshields »

I'm having a very hard time working out what you are asking! You want a text area to allow <code> ... </code> tags, which can contain PHP code, which when submitted will actually evaluate the code and replace the code and tags with the result?

It already sounds like an enormous security hole, but if you post some more code, preferably in [ php ] tags, and use better punctuation, someone will probably help.
Post Reply