請注意,此函式的傳回值是一個布林值,但 fseek 的傳回值是 0 表示成功,-1 表示失敗。
處理檔案時請使用以下實作
function stream_seek($offset, $whence) {
if(0 === fseek($this->_handler, $offset, $whence)){
return true;
}
return false;
}
(PHP 4 >= 4.3.2, PHP 5, PHP 7, PHP 8)
streamWrapper::stream_seek — 搜尋串流中的特定位置
注意:
如果未實作,則假設傳回值為
false
。
注意:
成功時,會在呼叫 streamWrapper::stream_seek() 之後直接呼叫 streamWrapper::stream_tell()。如果 streamWrapper::stream_tell() 失敗,則傳回呼叫端函式的值將設定為
false
。
注意:
並非所有對資料流的搜尋操作都會導致呼叫此函式。PHP 資料流預設啟用讀取緩衝區(另請參閱 stream_set_read_buffer()),並且可以僅透過移動緩衝區指標來執行搜尋。
請注意,此函式的傳回值是一個布林值,但 fseek 的傳回值是 0 表示成功,-1 表示失敗。
處理檔案時請使用以下實作
function stream_seek($offset, $whence) {
if(0 === fseek($this->_handler, $offset, $whence)){
return true;
}
return false;
}