|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[1999-07-23 18:55 UTC] sas at cvs dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 08 14:00:02 2026 UTC |
The following function will work only once when called multiple times. My guess is that the file pointer have to be reset (feof($fp) shows true after the first time the function is called). function get_data() { $fp = fsockopen("www.php.net", 80, &$errno, &$errstr); if (!$fp) { echo "$errstr ($errno)<br>\n"; $err = 1; } else { fputs($fp,"GET /quote.asp?Symbol=$ticker HTTP/1.0\n\n"); echo "$fp, ", feof($fp), "\n"; while(!feof($fp)) { $resp .= fgetss($fp,4096); } fclose($fp); } echo $resp; } Let's say I do the following: for ($i=0;$i<10;$i++) { echo "start...\n"; get_data(); } It will return valid output for the first time, and the rest will just be blank.