|
Home
iRate! IceMelon IM Tutorials Headlines CoolSites PHP Functions |
|
Most Referenced Functions » google_pagerank() » preg_replace() » site_pageranks() » imagecreatefrompng() » htmlentities() » imagepng() » imagestring() » imagedestroy() » preg_match() » imagecolorallocate() » header() » fopen() » getimagesize() » session_start() » strstr() » preg_match_all() » strpos() » ob_start() » ob_flush() » flush() » str_replace() » array2vars() » nl2br() » htmlspecialchars() » setcookie() » urlencode() » preg_split() » ereg() » ereg_replace() » var_dump() Our Sponsors » Powerpointing » Rock Music Community - meet fans » Business Strategy Become a sponsor for $15/month. Link is sitewide - PR5 homepage, 20+ PR4 pages, 90+ PR3 pages. Email dave[AT]icemelon[D0T]c0m.
Local search Connecticut furniture stores can be found at FurnitureCatch:
Furniture Stores Norwalk,
Furniture Stores Stamford,
Furniture Stores Greenwich,
Furniture Stores New Canaan,
Furniture Stores Darien
|
PHP Functions
Function: fread (PHP 3, PHP 4, PHP 5) fread -- Binary-safe file readDescriptionstring fread ( resource handle, int length )fread() reads up to length bytes from the file pointer referenced by handle . Reading stops when length bytes have been read, EOF (end of file) is reached, or (for network streams) when a packet becomes available, whichever comes first.
<?php // get contents of a file into a string $filename = "/usr/local/something.txt"; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); fclose($handle); ?>
Warning On systems which differentiate between binary and text files (i.e. Windows) the file must be opened with 'b' included in fopen() mode parameter.
<?php $filename = "c:\\files\\somepic.gif"; $handle = fopen($filename, "rb"); $contents = fread($handle, filesize($filename)); fclose($handle); ?>
Warning When reading from network streams or pipes, such as those returned when reading remote files or from popen() and fsockopen() , reading will stop after a packet is available. This means that you should collect the data together in chunks as shown in the example below.
<?php
$handle = fopen("http://www.example.com/", "rb");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
?>
Note: If you just want to get the contents of a file into a string, use file_get_contents() as it has much better performance than the code above. Related Function(s) |