Home > Backend Development > PHP Tutorial > PHP file reading and writing

PHP file reading and writing

WBOY
Release: 2016-07-25 08:45:23
Original
866 people have browsed it
  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() failn" ;
  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


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template