- <?php
- $handle = @ fopen ( "demo.txt" , "r" );
- if ( $handle ) {
- while (( $buffer = fgets ( $handle , 4096 )) !== false ) {
- echo $buffer ;
- }
- if (! feof ( $handle )) {
- echo "Error: unexpected fgets() fail\n" ;
- }
- fclose ( $handle );
- }
- echo '<hr/>';
- $length= readfile("demo.txt");
- echo '<hr/>';
- $file_str = 'demo.txt';
- if(file_exists($file_str))
- {
- echo file_get_contents($file_str);
- }
- ?>
来源: http://www.phpxs.com/code/1003393/