Skip to content

Instantly share code, notes, and snippets.

@kiall
Created January 30, 2012 01:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiall/1701859 to your computer and use it in GitHub Desktop.
Save kiall/1701859 to your computer and use it in GitHub Desktop.
<?php
class Cache {
protected $cache = array();
function set($value)
{
if (is_object($value))
$this->cache = clone $value;
$this->cache = $value;
}
function get()
{
if (is_object($this->cache))
return clone $this->cache;
return $this->cache;
}
}
$cache = new Cache;
$a = new stdClass();
$a->test = "one";
$cache->set($a);
$a->test = "two";
$b = $cache->get();
echo $b->test; // I want this to echo one :(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment