In php, the phpfwrite () function is used to write files (which can be safely used for binary files ). Simply put, add new content to a file. This article collects and summarizes several summary about the usage of fwrite () functions in php writing
The same point: the File_put_contents () function writes a string to a file, which is called fopen (), fwrite (), and fclose () in turn.
Different points: using File_append in the file_put_contents () function avoids deleting what is already in the
PHP write files, PHP and ASP can be the same as the operation of the file,fwrite to write the file
Now that you know how to open and close a file, you can get the most useful part of the file operation, write! There is really only one main
PHP function fwrite-write a file (which can be safely used for binary files)
Description
Int fwrite (resource handle, string [, int length])
The PHP function fwrite writes the string content to the handle of the file pointer. If length is specified,
PHP function fwrite--write file (can be used safely for binary files)
Description
int fwrite (resource handle, string string [, int length])
The PHP function fwrite writes the contents of a string to the file pointer handle. If length is specified,
Can PHP fwrite be executed concurrently? PHPcode $ f2 = fopen ('File/index.txt ', 'w'); fwrite ($ f2, $ h. $ old); fclose ($ f2); E. g.: make a message board. I did not use the mysqlsoftware. directly write the message into a. txt file. what if the
We all know the line break in PHP: \ n, carriage return: \ r, when you need to change lines, it's usually a combination of "\ r \ n". But why does the newline character not work when we write a file using fwrite? Let's look at the following example:
{Code ...} for example, if I write aa $ msg on the keyboard, the problem is that $ msg is not & quot; input & quot; or & quot; input aa & quot ;, and why does the program stop there for input? Shouldn't php be executed directly?
Fwrite (STDOUT,
Command: File_put_contents ();
Command parsing: file_put_contents (PHP 5)
File_put_contents--Writes a string to the file
Description
int file_put_contents (string filename, string data [, int flags [, resource context]])
and sequentially call fopen
PHP fwrite can be executed concurrently?
PHP Code
$f 2 = fopen (' File/index.txt ', ' W '); Fwrite ($f 2, $h. $old); fclose ($f 2);
For example: Make a message board. No software such as MySQL is used. Write the message directly into
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.