JStream/gets: Difference between revisions
From Joomla! Documentation
m clean up |
m preparing for archive only |
||
| Line 1: | Line 1: | ||
===Syntax=== | ===Syntax=== | ||
<source lang="php">gets($length=0)</source> | <source lang="php">gets($length=0)</source> | ||
| Line 60: | Line 58: | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=gets | category=gets | ||
category=JStream | category=JStream | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
Latest revision as of 02:07, 25 March 2017
Syntax
gets($length=0)
| Parameter Name | Default Value | Description |
|---|---|---|
| $length | 0 |
Defined in
libraries/joomla/filesystem/stream.php
Importing
jimport( 'joomla.filesystem.stream' );
Source Body
function gets($length=0)
{
if(!$this->_fh)
{
$this->setError(JText::_('File not open'));
return false;
}
$retval = false;
// Capture PHP errors
$php_errormsg = 'Error Unknown';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
switch($this->processingmethod)
{
case 'gz':
$res = $length ? gzgets($this->_fh, $length) : gzgets($this->_fh);
break;
case 'bz':
case 'f':
default:
$res = $length ? fgets($this->_fh, $length) : fgets($this->_fh);
break;
}
if(!$res) {
$this->setError($php_errormsg);
} else {
$retval = $res;
}
// restore error tracking to what it was before
ini_set('track_errors',$track_errors);
// return the result
return $retval;
}
Examples
Code Examples