Home >Backend Development >PHP Tutorial >PHP text operation method collection comparison page 1/2_PHP tutorial
String reading and writing functions fgets and fputs
1. Reading string function The function of fgets function is to read a string from the specified file into a character array. The function call is in the form: fgets (character array name , n, file pointer); where n is a positive integer. Indicates that the string read from the file does not exceed n-1 characters. Add the end-of-string mark ' after the last character readLine 16 of the program opens the binary file "stu_list" in read-write mode. After inputting two student data, it is written into the file. Then the internal position pointer of the file is moved to the beginning of the file. After reading out the two * blocks, it is displayed on the screen. show.