This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
uphp:functions:fwrite [2017/07/06 11:38] admin |
uphp:functions:fwrite [2021/09/13 05:57] (current) |
||
---|---|---|---|
Line 20: | Line 20: | ||
</ | </ | ||
- | This function performs a binary-safe write of strings or bytes specified by integers to a previously opened resource((< | + | This function performs a binary-safe write of strings or bytes specified by integers to a previously opened resource((< |
====Parameters==== | ====Parameters==== | ||
Line 75: | Line 75: | ||
====Note==== | ====Note==== | ||
+ | |||
When working with binary data such as data read from a file using fread(), make sure to pass the variable as a pointer using the & symbol. | When working with binary data such as data read from a file using fread(), make sure to pass the variable as a pointer using the & symbol. | ||
Line 88: | Line 89: | ||
} else $buflen=$len; | } else $buflen=$len; | ||
$data = fread($fo, | $data = fread($fo, | ||
- | // make sure you also specify the optional file size or else it will use the length of the string (till the first null) | + | // make sure you also specify the optional file size |
- | // pass the variable by reference | + | // |
+ | // | ||
| | ||
$len = $len - $buflen; | $len = $len - $buflen; | ||
Line 95: | Line 97: | ||
fclose($fh); | fclose($fh); | ||
fclose($fo); | fclose($fo); | ||
- | | ||
?> | ?> | ||
</ | </ | ||
+ | |||
====See Also==== | ====See Also==== | ||