1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- --TEST--
- Test fopen and fclose() functions - usage variations - "w+" mode
- --FILE--
- <?php
- $file_path = __DIR__;
- require($file_path."/file.inc");
- create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 4, "bytes");
- $file = $file_path."/007_variation4.tmp";
- $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
- echo "*** Test fopen() & fclose() functions: with 'w+' mode ***\n";
- $file_handle = fopen($file, "w+");
- var_dump($file_handle);
- var_dump( get_resource_type($file_handle) );
- var_dump( ftell($file_handle) );
- var_dump( fwrite($file_handle, $string) );
- var_dump( ftell($file_handle) );
- rewind($file_handle);
- var_dump( fread($file_handle, 100) );
- var_dump( ftell($file_handle) );
- var_dump( fclose($file_handle) );
- var_dump( get_resource_type($file_handle) );
- var_dump( filesize($file) );
- clearstatcache();
- fclose( fopen($file, "w+") );
- var_dump( filesize($file) );
- clearstatcache();
- unlink($file);
- fclose( fopen($file, "w+") );
- var_dump( file_exists($file) );
- echo "*** Done ***\n";
- --CLEAN--
- <?php
- unlink(__DIR__."/007_variation4.tmp");
- ?>
- --EXPECTF--
- *** Test fopen() & fclose() functions: with 'w+' mode ***
- resource(%d) of type (stream)
- string(6) "stream"
- int(0)
- int(37)
- int(37)
- string(37) "abcdefghij
- mnopqrst uvwxyz
- 0123456789"
- int(37)
- bool(true)
- string(7) "Unknown"
- int(37)
- int(0)
- bool(true)
- *** Done ***
|