Just wanted to let everyone else know so they don't waste days trying to
figure it out.
When using fread() on just about anything except for a file, it only
reads one packet at a time.
This means you must fread within a loop to read the bytes you need.
You can no longer pass "$length bytes to be read".

http://bugs.php.net/bug.php?id=24033 for details,  which was classified
as Bogus (Wez states this is the expected behavior of PHP, he fails to
recognize that it is not the expected behavior of the developers that
have been using PHP for years)

The little Note: in the documentation was NOT enough of a notice for
such a large change in functionality.

Code like this:

$fp = fopen('http://finance.yahoo.com/quote.php?q=MSFT', 'r');
$data = fread($fp, 100000);

will no longer work, now you must:

$fp = fopen('http://finance.yahoo.com/quote.php?q=MSFT', 'r');
do {
        $_data = fread($fp, 8192);
        if (strlen($_data) == 0) break;
        $data .= $_data;
}

or some other similar looping of your choice.

Hope this helps someone else from wasting days trying to figure out why
their code no longer works.

Bob Silva




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to