PHP: trying to get fgets() to trigger both on CRLF, CR and LF
问题 I'm reading streams in PHP, using proc_open and fgets($stdout), trying to get every line as it comes in. Many linux programs (package managers, wget, rsync) just use a CR (carriage return) character for lines which periodically updates "in place", like download progress. I'd like to catch these updates (as separate lines) as soon as they happen. At the moment, fgets($stdout) just keeps reading until a LF, so when progress is going very slowly (big file for example) it just keeps on reading