fwrite – PHP Reference Book Blog https://phpreferencebook.com/ PHP Reference: Beginner to Intermediate PHP5 Sun, 01 Oct 2017 17:21:19 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.13 fwrite() has a Double Tip that is Misplaced https://phpreferencebook.com/corrections/fwrite-double-tip-misplaced/ Mon, 21 Dec 2009 12:00:09 +0000 https://phpreferencebook.com/?p=346 Continue reading fwrite() has a Double Tip that is Misplaced]]> On page 131, the fwrite() function has a TIP that reads:
 
To read the entire file into a string, use the function filesize().

// file.txt contains the sentence: Hello World!
$filename = 'file.txt';
$file = fopen($filename, 'r');
$string = fread( $file, filesize($filename) );
var_dump($string);
// file.txt now contains at the end: Hello World!

You’ll notice that this is the same tip as fread() and doesn’t belong. It should be considered ‘removed’.

]]>