HttpResponse::send

(PECL pecl_http >= 0.10.0)

HttpResponse::sendSend response

Description

static bool HttpResponse::send ([ bool $clean_ob = true ] )

Finally send the entity.

A successful caching attempt will exit PHP, and write a log entry if the INI setting http.log.cache is set. See the INI setting http.force_exit for what "exits" means.

Parameters

clean_ob

whether to destroy all previously started output handlers and their buffers

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 A HttpResponse::send() example

<?php
HttpResponse
::setCache(true);
HttpResponse::setContentType('application/pdf');
HttpResponse::setContentDisposition("$user.pdf"false);
HttpResponse::setFile('sheet.pdf');
HttpResponse::send();
?>

See Also

[an error occurred while processing the directive]

Коментарии

I was having a problem with the bytes appended to the output, using the given example. 

<?php
...
HttpResponse::setFile('sheet.pdf');
HttpResponse::send();
?>

Content-Length mismatch: Response Header claimed x bytes, but server sent x+5 bytes.

Adding an exit statement solved this problem.
2008-05-26 00:31:35
http://php5.kiev.ua/manual/ru/httpresponse.send.html
Автор:
how to respond to a http request
Note that if you output data before sending the response then you will get a warning saying: Cannot modify header information - headers already sent. So do not echo any data in your responding script. 
<?php
//process the request by fetching the info
$headers http_get_request_headers();
$result http_get_request_body();
//do stuff with the $headers and $result variables....
//then send your response
HttpResponse::status(200);
HttpResponse::setContentType('text/xml');
HttpResponse::setHeader('From''Lymber');
HttpResponse::setData('<?xml version="1.0"?><note>Thank you for posting your data! We love php!</note>');
HttpResponse::send();
?>
2010-01-18 23:35:19
http://php5.kiev.ua/manual/ru/httpresponse.send.html

    Поддержать сайт на родительском проекте КГБ