Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What type does fwrite() returns?

Tags:

php

return

fwrite

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

like image 806
MEM Avatar asked Dec 21 '22 23:12

MEM


2 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 just before the function name. It returns FALSE on error:

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

like image 131
Andy E Avatar answered Jan 07 '23 11:01

Andy E


An integer, or boolean false on failure.

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

var_dump($bytes); // output: int(13)
like image 20
Annika Backstrom Avatar answered Jan 07 '23 10:01

Annika Backstrom