Enn Fenn
Enn Fenn

Reputation: 420

PHP fgets reading wrong chunk size

I am trying to read chunks of specific length from an mp4 file:

$fp = fopen('file.mp4', 'rb');
$line = fgets($fp, 204800);
echo strlen($line);

I suppose it should output 204800 but it only prints 1547. Any idea what is wrong here?

Upvotes: 1

Views: 306

Answers (1)

denisvm
denisvm

Reputation: 730

You are looking for fread().

fgets() keeps reading until length-1, newline or EOF.

You are probably getting a 0xa (10, \n) byte.

Upvotes: 4

Related Questions