oozo Posted June 28, 2006 Share Posted June 28, 2006 Hi i have a database in wich I want to store php code. Using eval I can easily execute the php exept when I want to load a template in this file.Expample:a DB cell contains:<? $array = array(1=>'bla', 2=>'bla2', 3=>'bla3');foreach ($array as $v){ echo $v. "<br>";} ?><form name="tesdt" action="eeee" method="post"> <input type="text" name="ttt" value="ttttt" /> </form> This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.<? echo "hello" ?>I would like to extract the php bits so I can eval these bits.Can anybody help me? I am not very good in preg stuff.Cheers and thanks! Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted June 29, 2006 Share Posted June 29, 2006 I can't see why you would need to do any pattern matching on this...eval should work fine with breaking out of php.also itr is recommended that you do not use the short hand tags - use <?php instead!!! Quote Link to comment Share on other sites More sharing options...
Nooty Posted December 17, 2006 Share Posted December 17, 2006 [quote author=ToonMariner link=topic=97062.msg389181#msg389181 date=1151574878]I can't see why you would need to do any pattern matching on this...eval should work fine with breaking out of php.also itr is recommended that you do not use the short hand tags - use <?php instead!!![/quote]i have been looking into this subject a lot recently..the code will be stored as a string, so if you were to eval that string you would get an error (try putting that all in a php file and running it :P)im thinking you would need to do a preg_replace_callback, find the code with a reg expression eg - "/<?(.8)?>/siU" and then have a function to eval the code and return the result.i understand this is an old topic, but if i could have found the solution to this problem when i was looking then i wouldnt have spent hours trying to figure it out. i hope this helps someone. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.