fopen() Binds the name resource specified by file to a stream. filesize returns the file size in bytes, or FALSE if an error occurs. Note: Because PHP's integer types are signed, and most platforms use 32-bit integers, the filesize() function may return unexpected results when encountering files larger than 2GB. For files between 2GB and 4GB, it is usually You can use sprintf("%u", filesize($file)) to overcome this problem. fread() reads up to length bytes from the file pointer handle. This function stops reading the file after reading length bytes, or when EOF is reached, or (for network streams) when a packet is available. , it depends on which situation is encountered first. Note: Low version usage! It is recommended to use file_get_contents for php5 Example 2,
file -- Read the entire file into an array illustrate Read binary files Example 3,
file_get_contents - - Read the entire file into a string illustrate string file_get_contents ( string filename [, int use_include_path [, resource context]]) Same as file(), except file_get_contents() returns the file as a string. The file_get_contents() function is the preferred method for reading the contents of a file into a string. If the operating system supports it, memory mapping technology will also be used to enhance performance. The above has shared three examples of PHP code to obtain remote files. I hope it will be helpful to everyone. |