<?php
    class Base {
        private static $cache = array();

        public function &__get($name) {
            if ($name != 'cache') {
                // error handling
            }

            $type = get_class($this);
            if (!isset(self::$cache[$type])) {
                self::$cache[$type] = array();
            }

            return self::$cache[$type];
        }
    }

    class Derived extends Base {
    }
    
    $b = new Base;
    $b2 = new Base;
    $d = new Derived;
    $b->cache['foo'] = 42;

    echo $b->cache['foo']."\n";  // 42
    echo $b2->cache['foo']."\n"; // also 42
    echo $d->cache['foo']."\n";  // nothing (actually, undefined index); cache is per-class
