|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[1999-06-18 11:53 UTC] sas at cvs dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 08 11:00:02 2026 UTC |
Hi, The following code often works, however, on some URLs it fails with the following strange error: Warning: fopen("http://www.lysator.liu.se/mit-guide/mit-guide.html","r") - Success in /home/vic/public_html/mywall/bug.phtml on line 9 Even though it says success, it's acting like its timing out and the handle returned is null. I can telnet to the server and issue a get command by hand and it works fine, so I am guessing that it is a problem with PHP. I haven't had time to look at the PHP source code but I thought I'd at least let you know about the problem. If it matters, I am using this with Apache 1.3.6 and postgresql. function GetTitle($url) { $cnt=3; while (!($fp=fopen($url, "r"))) { $cnt--; if (!$cnt) break; sleep(5); echo "Failed opening ".$url; } if ($fp) { $buf=fread($fp, 4096); if ($s=strpos(strtoupper($buf), "<TITLE>")) { $s+=7; $e=strpos(strtoupper($buf), "</TITLE>"); $title=trim(substr($buf, $s, $e-$s)); } else { $title="no title"; } fclose($fp); } else { $title="WARNING: Couldn't open ".$url; } return($title); } echo GetTitle("http://www.lysator.liu.se/mit-guide/mit-guide.html");