How to write files in php

藏色散人
Release: 2023-02-24 10:28:01
Original
9194 people have browsed it

How to write files in php

php method of writing files

PHP writing files-fwrite()

fwrite() function is used to write files.

The first parameter of fwrite() contains the file name of the file to be written, and the second parameter is the string to be written.

The following example writes the name to a new file named "newfile.txt":

Example

Copy after login

Please note that we write the name to the file "newfile.txt" Wrote it twice. Each time we write to the file, the string $txt we send contains "Bill Gates" the first time and "Steve Jobs" the second time. After writing is complete, we use the fclose() function to close the file.

If we open the "newfile.txt" file, it should look like this:

Bill Gates
Steve Jobs
Copy after login

For more PHP knowledge, please visit the PHP Chinese website PHP Tutorial!

The above is the detailed content of How to write files in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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 [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!