JResponse/toString: Difference between revisions
From Joomla! Documentation
m clean up |
m preparing for archive only |
||
| Line 4: | Line 4: | ||
===Syntax=== | ===Syntax=== | ||
| Line 53: | Line 53: | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=toString | category=toString | ||
category=JResponse | category=JResponse | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
Latest revision as of 02:01, 25 March 2017
Description
Sends all headers prior to returning the string
Syntax
static toString($compress=false)
| Parameter Name | Default Value | Description |
|---|---|---|
| $compress | false | $compress If true, compress the data |
Returns
string
Defined in
libraries/joomla/environment/response.php
Importing
jimport( 'joomla.environment.response' );
Source Body
public static function toString($compress = false)
{
$data = self::getBody();
// Don't compress something if the server is going todo it anyway. Waste of time.
if ($compress && !ini_get('zlib.output_compression') && ini_get('output_handler')!='ob_gzhandler') {
$data = self::_compress($data);
}
if (self::allowCache() === false)
{
self::setHeader('Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true); // Expires in the past
self::setHeader('Last-Modified', gmdate("D, d M Y H:i:s") . ' GMT', true); // Always modified
self::setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false);
self::setHeader('Pragma', 'no-cache'); // HTTP 1.0
}
self::sendHeaders();
return $data;
}
Examples
Code Examples