Strings, Quotes and Encoding?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Buddha
    Senior Member
    • Mar 2004
    • 825

    #1

    Strings, Quotes and Encoding?

    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:

    PHP Code:
    $_VIEW['article_text'] = 'text of the article here'
    There are a number of problems with this...
    • 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'] = gzinflatebase64_decode'K0ktLtFNSixON' ) ); 
    Anyone have a simpler way to do this?
    "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha
Working...