API16

JStreamString/stream seek: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
New page: <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </span> {{Description:JStreamString/...
 
m clean up
Line 1: Line 1:
 
{{subst:Description:JStreamString/stream_seek}}
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JStreamString/stream_seek|Edit Descripton]]<nowiki>]</nowiki>
</span>
 
{{Description:JStreamString/stream_seek}}


===Syntax===
===Syntax===
Line 57: Line 52:
</source>
</source>


<span class="editsection" style="font-size:76%;">
 
<nowiki>[</nowiki>[[SeeAlso:JStreamString/stream_seek|Edit See Also]]<nowiki>]</nowiki>
{{subst:SeeAlso:JStreamString/stream_seek}}
</span>
{{SeeAlso:JStreamString/stream_seek}}


===Examples===
===Examples===

Revision as of 14:27, 24 March 2017

{{subst:Description:JStreamString/stream_seek}}

Syntax

stream_seek($offset, $whence)
Parameter Name Default Value Description
$offset
$whence

Defined in

libraries/joomla/filesystem/streams/string.php

Importing

jimport( 'joomla.filesystem.streams.string' );

Source Body

function stream_seek($offset, $whence) {
        //$whence: SEEK_SET, SEEK_CUR, SEEK_END
        if($offset > $this->_len) {
                return false; // we can't seek beyond our len
        }
        switch($whence)
        {
                case SEEK_SET:
                        $this->_pos = $offset;
                        break;
                case SEEK_CUR:
                        if (($this->_pos + $offset) < $this->_len) {
                                $this->_pos += $offset;
                        }
                        else {
                                return false;
                        }
                        break;
                case SEEK_END:
                        $this->_pos = $this->_len - $offset;
                        break;
        }
        return true;
}


{{subst:SeeAlso:JStreamString/stream_seek}}

Examples

<CodeExamplesForm />