public function sendResponse($response) { // i think json_spirit rejects \/ even tho it's valid json. doh. $str = str_replace('\\/', '/', json_encode($response)); print pack('N', strlen($str)); print $str; }