当前位置:Gxlcms > PHP教程 > PHP文件读写

PHP文件读写

时间:2021-07-01 10:21:17 帮助过:3人阅读

  1. $handle = @ fopen ( "demo.txt" , "r" );
  2. if ( $handle ) {
  3. while (( $buffer = fgets ( $handle , 4096 )) !== false ) {
  4. echo $buffer ;
  5. }
  6. if (! feof ( $handle )) {
  7. echo "Error: unexpected fgets() fail\n" ;
  8. }
  9. fclose ( $handle );
  10. }
  11. echo '
    ';
  12. $length= readfile("demo.txt");
  13. echo '
    ';
  14. $file_str = 'demo.txt';
  15. if(file_exists($file_str))
  16. {
  17. echo file_get_contents($file_str);
  18. }
  19. ?>

PHP

人气教程排行