Page 1 of 1

Trivial Response Object

Posted: Fri Oct 05, 2007 3:18 pm
by alex.barylski
I don't need the abstraction of Zend, really something as simple as possible but that still meets the requirements of most web based applications (no CLI, etc).

Does anyone have any input on the following psuedo-response object?

Have you ever encountered a situation where you needed to clear previously pushed headers? Can you give me an example of when that might be needed from a real life experience? That is an example of a missing function.

Code: Select all

class QC_Response{

	/* private */ var $_head = null;
	/* private */ var $_buff = '';

	function addHeader($name, $value){ $this->_head[$name] = $value; }
	function getHeader($name){ return $this->_head[$name]; }


	function setContent($text){ $this->_buff = $text; }
	function getContent(){ return $this->_buff; }

	function fetchResponse($auto = false)
	{
		$arr = $this->_head;
		foreach($arr as $key => $value)
			header("$key: $value");

		if($auto)
			echo $this->_text;
		else
			return $this->_text;
	}
}

Posted: Fri Oct 05, 2007 5:29 pm
by Christopher
Well you already have the abstraction of Zend. If you want simpler then remove the get*() methods. I also have always thought that $auto is a pretty variable name.