Question

On the php manual we can read:

fwrite() returns the number of bytes written

Ok... but what kind of thing is "number of bytes written"?

Binary string? Binary number? Stream? Int?

I'm a little bit lost here.

Regards

Was it helpful?

Solution

From the manual:

Description

int fwrite ( resource $handle , string $string [, int $length ] )

It returns an int on success, as indicated by the type name just before the function name. It returns FALSE on error:

fwrite() returns the number of bytes written, or FALSE on error.

OTHER TIPS

An integer, or boolean false on failure.

$fh = fopen('/tmp/bar', 'w');
$bytes = fwrite($fh, 'Hello, world.');

var_dump($bytes); // output: int(13)

I found the case that fwrite returns NULL with E_NOTICE error.
Probably this occurs when network stream aborted.

Notice: fwrite(): in .... on line ....
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top