I've been working on a CMS that is file based by this I mean for every page there's an actual file. There's also database records too. However, my problem concerns the file. The CMS creates a PHP pages in which static data is placed in string variables. This is done to avoid hitting the database for information the doesn't change. Something like this:
There are a number of problems with this...
The solution I came up with was to base64 encode the string. To avoid the increased in size that base64 encoding adds, I added gzdeflate too. So now I have a string the looks like:
Anyone have a simpler way to do this?
PHP Code:
$_VIEW['article_text'] = 'text of the article here';
- Need to escape single quotes.
- Need to preserve actual backslashes.
- Quoting will try to parse backslashes and drops those it does not recognize and make changes when it does.
The solution I came up with was to base64 encode the string. To avoid the increased in size that base64 encoding adds, I added gzdeflate too. So now I have a string the looks like:
PHP Code:
$_VIEW['article_text'] = gzinflate( base64_decode( 'K0ktLtFNSixON' ) );