note 40803 added to function.fopen

From: Date: Mon, 15 Mar 2004 13:32:14 +0000
Subject: note 40803 added to function.fopen
Groups: php.notes 
Request: Send a blank email to php-notes+get-66861@lists.php.net to get a copy of this message
fopen() will not work (PHP <= 4.3.3) getting data from a URL + QUERY_STRING, like: http://www.example.com/example.php?IdCategory=4 or http://www.receitas.com.br/Receitas.asp?Receita=Caipirinha A solution I found to do that is to use functions of CURL Library. I think CURL get HTML final result of webserver... fopen() try to open file. <?php //Does not work using fopen(): $url = "http://www.example.com/example.php?IdCategory=4"; function extrair_url_fopen ($url) { $filename = $url; $handle = fopen ($filename, "r"); $conteudo = fread ($handle, filesize ($filename)); fclose ($handle); return $conteudo; } //It works using CURL: $url = "http://www.example.com/example.php?IdCategory=4"; function extrair_url_curl ($url) { $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_HEADER, 0); ob_start(); curl_exec ($ch); curl_close ($ch); $string = ob_get_contents(); ob_end_clean(); return $string; } ?> Luiz Miguel Axcar Campinas, São Paulo, Brasil ---- Manual Page -- http://www.php.net/manual/en/function.fopen.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40803 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40803&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40803&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#66861) next »