首頁  >  文章  >  後端開發  >  PHP文件读写

PHP文件读写

WBOY
WBOY原創
2016-07-25 08:45:23787瀏覽
  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


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn