What type does fwrite () return?

In the php manual we can read:

fwrite () returns the number of bytes written

Ok ... but what is this "number of bytes written"?

Binary string Binary number? Flow? Int?

I'm a little lost here.

Hi

+4
source share
3 answers

From the manual :

Description

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

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

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

+10
source

An integer or boolean false on error.

 $fh = fopen('/tmp/bar', 'w'); $bytes = fwrite($fh, 'Hello, world.'); var_dump($bytes); // output: int(13) 
+1
source

I found a case where fwrite returns NULL with an E_NOTICE error.
This probably occurs when the network stream is interrupted .

 Notice: fwrite(): in .... on line .... 
0
source

All Articles