Hi,

On 6/3/07, pat <[EMAIL PROTECTED]> wrote:
To Till,
Your arguments are cogent enough, much better than winking.  I didn't
know that about the cache. I'll keep it in mind.  That whole segment was
cut and pasted out of my bootstrap file.  Somehow I missed deleting it
when I sanitized it for public viewing.  As for the Global, I generally
agree with you, but this global is different, it has superpowers.;)

I'll include the code.  You can wink at it all you like, it isn't mine.
I pinched it off the net.

It was nothing personal. I have no idea what you are serializing
there, it looks weird though.

<?php
define("APP_DATA_FILE",realpath(make_private_path("/app/data/application.data")));
function application_start ()
{
    global $_APP;

    // if data file exists, load application
    //   variables
    if (file_exists(APP_DATA_FILE))
    {
        // read data file
        $file = fopen(APP_DATA_FILE, "r");
        if ($file)
        {
            $data = fread($file,
                filesize(APP_DATA_FILE));
            fclose($file);
        }
        // build application variables from
        //   data file
        $_APP = unserialize($data);
    }
}

function application_end ()
{
    global $_APP;

    // write application data to file
    $data = serialize($_APP);
    $file = fopen(APP_DATA_FILE, "w+");
    if ($file)
    {
        fwrite($file, $data);
        fclose($file);
    }
}

Looking at what you do, you may want to check out Zend_Config (along
with Zend_Cache) - but that's just a wild guess since I don't know
what kind of data you are reading/serializing there.

Cheers,
Till

Reply via email to