For an application I'm writing I have different versions of a page stored in a database. I want to have a few lines of PHP and then spit out the correct version from the database.
If I generate an actual file for each version I can include it no problem. Is there something like include that I can use to import the code from the database.
I can't just echo because then PHP code doesn't get processed. I can't eval() because it doesn't like <?php ?> tags.
Any ideas?
Can I "include" text that isn't a file?
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Strip the <?php tags with something trivial like:
A database is not necessarily less secure than a file system, so eval() should be fine.
Code: Select all
substr($buffer, 5, strlen($buffer)-7);
eval($buffer);(#10850)
Stripping out the php tags isn't really an option. There are some cases where there might be nested PHP in a textarea that isn't meant to be eval'd. I could write something complicated, but I'm not confident I can think of every possible case.
I'm building a multivariate testing platform, so I the input could be anything. Storing to files is fine, but then I have to deal with permissions and such. I guess if there's no clean option, that's what I'll do.
Tynan
I'm building a multivariate testing platform, so I the input could be anything. Storing to files is fine, but then I have to deal with permissions and such. I guess if there's no clean option, that's what I'll do.
Tynan