Home  >  Article  >  Backend Development  >  Simple method to read and write files in PHP_PHP Tutorial

Simple method to read and write files in PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:26:441010browse

Read the file contents and write to the variable $contents:  

Write the contents of the variable $contents to the file:

Of course, we can also use file_get_contents and file_put_contents to read and write files.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/822517.htmlTechArticleRead the file contents and write to the variable $contents: ?php $fp=fopen('file.txt', 'r'); $contents=fread($fp,filesize('file.txt')); fclose($fp); ? Write the contents of the variable $contents to the file: ?...
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