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

PHP file reading and writing

WBOY
WBOYOriginal
2016-07-25 08:45:23790browse
  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


Statement:
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