Source for file Application.php
Documentation is available at Application.php
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Richard Heyes <richard@phpguru.org> |
// +----------------------------------------------------------------------+
// $Id: Application.php 315102 2011-08-17 19:38:20Z cweiske $
require_once 'Cache.php';
// Application level variables
// Variables that are persisent across all user sessions,
// not just a specific user ala normal sessions.
// $app =& new Cache_Application();
// $_APP =& $app->getData();
// In this case the $_APP variable is akin to the $_SESSION variable.
// If you add/remove stuff, it will be reflected in the next request
// $bar = 'Some other data';
// $app =& new Cache_Application();
// $app->register('foo');
// $app->register('bar', $bar);
// $foo = 'Different data';
// In this case the variables are registered with the register() function.
// This is akin to session_register().
// As with session_register(), the contents of the variable at the *end* of the
// request is registered and not at the point of registration. Therefore in this
// example, for the $foo variable, the string 'Different data' is stored and not
// 'Some data'. The exception to this rule is if you use the second argument to
// register() as in the second call to it above. This will cause the data supplied
// in the second argument to be stored and not the contents at the end of the request.
// Note: If you use this method with register_globals turned on, the variables will be
// automatically globalled upon startup, (ie. when you create the object).
// Note: If you register a variable that is not set when the script finishes, it will
// *** You are strongly recommended to use only one method of the two above. ***
// (In fact if you use the register() function with register_globals Off, you have to
// use the $_APP method to get at the data).
* @param string Name of container class
* @param array Array with container class options
function Cache_Application($container = 'file', $container_options = array ('cache_dir' => '/tmp/', 'filename_prefix' => 'cache_'), $id = 'application_var', $group = 'application_cache')
$this->Cache($container, $container_options);
// If register_globals on, global all registered variables
foreach ($this->data as $key => $value) {
* Gets values of all registered variables and stores them. Then calls save() to
// Get contents of all registered variables
$this->data[$varname] = $ $varname;
* Registers a variable to be stored.
* @param string Name of variable to register
* @param mixed Optional data to store
function register($varname, $data = null )
$this->data[$varname] = $data;
* Unregisters a variable from being stored.
* @param string Name of variable to unregister
if (isset ($this->data[$varname])) {
unset ($this->data[$varname]);
* Removes all stored data
* Use this to get a reference to the data to manipulate
* in calling script. Eg. $_APP =& $obj->getData();
* @return mixed A reference to the data
Documentation generated on Mon, 11 Mar 2019 15:44:49 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|