note 50637 added to function.fread
| From: | fenris_wolf0 at yahoo dot com | Date: | Sat, 05 Mar 2005 10:59:56 +0000 |
| Subject: | note 50637 added to function.fread | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-85967@lists.php.net to get a copy of this message | ||
To make the effects of the latest PHP version changes of the fread function even more explicit: the
new size limitation of fread -regardless of the filesize one specifies, in the example below 1024 *
1024- means that if one was simply reading the contents of a text file from a dynamic URL like so:
<?
$dp = "http://www.whatever.com/filename.php";
$buffer = fopen($dp, 'r');
if (!$buffer)
{
echo("<P>Error: unable to load URL file into $buffer. Process
aborted.</P>");
exit();
}
$sp = fread($buffer, 1024*1024);
fclose($buffer);
highlight_string($sp);
?>
one should from now on use the file_get_contents function, as shown below, to avoid one's text
being truncated forcibly.
<?
$dp = "http://www.whatever.com/filename.php";
if (!$dp)
{
echo("<P>Error: unable to load URL file into $dp. Process
aborted.</P>");
exit();
}
$sp = file_get_contents($dp);
highlight_string($sp);
?>
I thought it couldn't hurt to clarify this detail in order to save time for anyone else who is
in the same situation as I was tonight when my ISP abruptly upgraded to the latest version of PHP...
:(
Thank you to every previous contributor to this topic.
----
Manual Page -- http://www.php.net/manual/en/function.fread.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50637
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50637&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50637&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50637&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50637&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50637&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50637&report=yes
Search -- http://master.php.net/manage/user-notes.php