Skip to content

Instantly share code, notes, and snippets.

@comfuture
Created May 16, 2011 08:33
Show Gist options
  • Save comfuture/974098 to your computer and use it in GitHub Desktop.
Save comfuture/974098 to your computer and use it in GitHub Desktop.
<?
class Response
{
private $headers = array();
private $body = '';
function __construct($body='', $headers=array())
{
$this->body = $body;
$this->headers = array_merge($this->headers, $headers);
}
public function __isset($key)
{
return in_array($key, array('headers', 'body'));
}
public function __get($key)
{
if (isset($this->{$key})) {
return $this->{$key};
}
}
public function __set($key, $value)
{
if (isset($this->{$key})) {
$this->{$key} = $value;
}
}
}
$resp = new Response();
$resp->headers[] = 'Content-Type: text/javascript'; // did not work!
$resp->headers = array(1,2,3); // work!
$resp->headers[] = 4; // did not work!!
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment