note 41532 deleted from function.fopen by cmb

From: Date: Sun, 09 Feb 2020 08:15:40 +0000
Subject: note 41532 deleted from function.fopen by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-214048@lists.php.net to get a copy of this message
Note Submitter: Jem Tallon ---- 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: <?php $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; } ?>

« previous php.notes (#214048) next »