__sleep and __wakeup:


// file.class.php
<?php
    class File {
        function File($filename) {
            $this->filename = $filename;
            $this->fp = fopen($filename, 'rb');
        }

        function seek($pos) {
            fseek($this->fp, $pos);
        }

        function __sleep() {
            $this->pos = ftell($this->fp);
            return array('fp', 'pos', 'filename');
        }   

        function __wakeup() {
            $this->fp = fopen($this->filename, 'rb');
            fseek($this->fp, $this->pos);
        }   
    }
? >