From: Trevor O. <tr...@gm...> - 2009-07-22 16:04:46
|
Only method I came up to do it on my blog was sort of a hack. I run a regular expression on the text to pick up the contents of all php tags (assuming php tags start with <?php and end with ?>. No other php tags), then I run this function on it: function evaluate_php($php){ ob_start(); eval($php); $output = ob_get_contents(); ob_end_clean(); return $output; } One thing to note with this is that it is potentially VERY insecure. If anyone else can add or change content, they can basically take over your server, so be careful with forms, and don't run comments through the same function. 2009/7/22 Andy Carlson <bng...@gm...> > Here's the situation. I'm designing a database based page generation > system > for my website. That is, HTML and possibly PHP code is stored in a MySQL > table as raw text. A query will pull the text out of the table and render > it as HTML and PHP. It renders the HTML, but it won't render the PHP Code > (it appears in my source code when I "view source" in my browser). > > I have tried the "eval()" command, but that doesn't seem to work. Any > thoughts? Thanks much, > > Andy Carlson > Carlson Technology > --------------------------------------------------- > "Man's conquest of Nature turns out, in the moment of its consummation, to > be Nature's conquest of Man." -- C.S. Lewis > --------------------------------------------------- > "The ubiquity of the Internet is more important than the technology of the > Internet" -- Jeff Bezos > > ------------------------------------------------------------------------------ > _______________________________________________ > chiPHPug-discuss mailing list > chi...@li... > https://lists.sourceforge.net/lists/listinfo/chiphpug-discuss > -- -Trevor Oldak |