S
S
Sergey Pugovkin2018-03-27 16:03:21
PHP
Sergey Pugovkin, 2018-03-27 16:03:21

Why "Returns a string of length - 1 byte"?

php.net/manual/en/function.fgets.php
string fgets ( resource $handle [, int $length ] )

Returns a string of length - 1 bytes read from the file descriptor pointed to by the handle parameter.

Why else is this? So fgets($handle, 1) will return an empty string? (1 - 1 == 0)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SagePtr, 2018-03-27
@SagePtr

I guess for compatibility with the fgets C function, where the last character is reserved for \0.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question