From: matt d. <mm_...@ya...> - 2009-07-22 16:53:21
|
Perhaps if you sent the actual code... ________________________________ From: Andy Carlson <bng...@gm...> To: Chicago PHP User Group <chi...@li...> Sent: Wednesday, July 22, 2009 11:38:27 AM Subject: Re: [chiPHPug-discuss] PHP Code in a string That doesn't appear to work (for me anyway). would you just echo the returned value of the function? Andy Carlson Carlson Technology (815) 875-2824 41° 22' 35" N 89° 28' 10" W --------------------------------------------------- "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 On Wed, Jul 22, 2009 at 11:04 AM, Trevor Oldak <tr...@gm...> wrote: > 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 > > ------------------------------------------------------------------------------ > _______________________________________________ > chiPHPug-discuss mailing list > chi...@li... > https://lists.sourceforge.net/lists/listinfo/chiphpug-discuss > ------------------------------------------------------------------------------ _______________________________________________ chiPHPug-discuss mailing list chi...@li... https://lists.sourceforge.net/lists/listinfo/chiphpug-discuss |