Created
May 16, 2011 08:33
-
-
Save comfuture/974098 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
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