How does PHP handle binary mode versus text mode when opening files or streams?

When opening files or streams in PHP, it is important to specify whether you want to handle the data in binary mode or text mode. Binary mode treats the data as raw bytes, while text mode may perform newline conversions or other character encoding transformations. To specify binary mode, you can use the 'b' flag in the fopen function.

$file = fopen('example.txt', 'rb');
// Perform operations on the file in binary mode
fclose($file);