note 41532 added to function.fopen

From: Date: Tue, 13 Apr 2004 19:11:43 +0000
Subject: note 41532 added to function.fopen
Groups: php.notes 
Request: Send a blank email to php-notes+get-68088@lists.php.net to get a copy of this message
If you're using fopen to open a URL that requires authorization, you might need to force a HTTP/1.0 request for it since fopen won't support HTTP/1.1 requests. You can do that by setting your user_agent to one that is known only to support HTTP/1.0 (most webservers will be configured to force HTTP/1.0 for some browsers). Here's what worked for me: $returned=URLopen("http://$username:$password@example.com"); function URLopen($url) { // Fake the browser type ini_set('user_agent','MSIE 4\.0b2;'); $dh = fopen("$url",'r'); $result = fread($dh,8192); return $result; } ---- Manual Page -- http://www.php.net/manual/en/function.fopen.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41532 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41532&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41532&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#68088) next »