$str = serialize( $anObject ); file_put_contents( 'theFile.txt', $str ); $str = file_get_contents( 'theFile.txt' ); $anObject = unserialize( $str );