PHP 8.3.4 Released!

streamWrapper::stream_seek

(PHP 4 >= 4.3.2, PHP 5, PHP 7, PHP 8)

streamWrapper::stream_seekBusca la ubicación específica en un flujo

Descripción

public streamWrapper::stream_seek(int $offset, int $whence = SEEK_SET): bool

Este método es llamado en respuesta a fseek().

La posición de lectura/escritura del flujo debería ser actualizada según offset y whence.

Parámetros

offset

El flujo de desplazamiento a buscar.

whence

Valores posibles:

  • SEEK_SET - Establece la posición igual a offset bytes.
  • SEEK_CUR - Establece la posición de la ubicación actual más offset.
  • SEEK_END - Establece la posición al final del archivo más offset.

Valores devueltos

Devuelve true si la posición se ha actualizado, si no false.

Notas

Nota:

Si no está implementado, se asume que el valor devuelto es false

Nota:

Si se tuvo éxito, streamWrapper::stream_tell() se llama directamente, después de llamar a streamWrapper::stream_seek(). Si streamWrapper::stream_tell() falla, el valor devuelto a la función de llamada se establece en false

Nota:

No todas las operaciones de búsqueda de el flujo conllevan a la llamada de esta función. Los flujos de PHP tienen buffer para la lectura activado por defecto (véase también stream_set_read_buffer()) y la búsqueda se puede realizar con sólo mover el puntero del buffer.

Ver también

  • fseek() - Busca sobre un puntero a un fichero

add a note

User Contributed Notes 1 note

up
3
fb at tigermedia dot dk
9 years ago
Please notice that the return value of this function is a boolean but the return value of fseek is 0 for ok and -1 for failure.

Please use this implementation when working with files:

function stream_seek($offset, $whence) {
if(0 === fseek($this->_handler, $offset, $whence)){
return true;
}
return false;
}
To Top