What is the difference between fopen () function rr +? Fopen (), the following parameter,
For example, r
R +
What is the difference between a read-only mode and a read/write mode? why do we need to create a later mode?
Can I see through an instance?
Reply to discussion (solution)
R. only fread can be read, and fwrite cannot be written.
R +, both of which can overwrite data
$ Fn = 'abc.txt '; // file name to be operated: file_put_contents ($ fn, '000000'); // write the test data to readfile ($ fn); // take a look, the content is 12345 // r read-only mode $ fp = fopen ($ fn, 'r'); $ c = fgetc ($ fp); echo $ c; echo fputs ($ fp, 'A'); // 0 No character is written into fclose ($ fp); readfile ($ fn); // take a look, the content is 12345 and the read/write mode is not changed. // r + $ fp = fopen ($ fn, 'R + '); $ c = fgetc ($ fp); echo $ c; echo fputs ($ fp, 'A'); // 1 write 1 character fclose ($ fp); readfile ($ fn); // check again, the content is 1a345
R can only read the content, but has no permission to write to the file.
R + can be written inside