Hi all, this is mine first attempt with php and I immediatly get stuck! :eek:
I'm working on a win7 64bit, i have installed wamp 2.1 and eclipse as ide and xdebug as debugger. (for php i have memory_limit set to 128M and the error flag to E_ALL)
I'm trying to read a web page and extract some info from it.
As first step i read the page with file_get_contents() but i always get only 1024 bytes into the $buffer variable.
Thinking for some protocol issue then i tried with these code to read the page:
require('httpclient/http.php');
function get_html_file($url, $cookie, $method, $values) {
$buffer = "";
if (!isset($method))
$method='GET';
set_time_limit(0);
$http=new http_class;
$http->timeout=0;
$http->data_timeout=0;
$http->debug=0;
$http->html_debug=0;
$http->user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
$http->follow_redirect=1;
$http->redirection_limit=5;
$http->exclude_address="";
$http->prefer_curl=1;
$error=$http->GetRequestArguments($url, $arguments);
$arguments["Headers"]["Pragma"]="nocache";
$arguments["RequestMethod"]=$method;
if ($method=='POST'){
$arguments["PostValues"]=$values;
}
if (isset($cookie)){
$cookie_name=$cookie['name'];
$cookie_value=$cookie['value'];
$cookie_expires=""; // "" for session cookies
$cookie_uri_path="/";
$cookie_domain=$cookie['domain'];
$cookie_secure=0; // 1 for SSL only cookies
$http->SetCookie($cookie_name, $cookie_value, $cookie_expiry, $cookie_uri_path, $cookie_domain, $cookie_secure);
}
$error=$http->Open($arguments);
if($error=="") {
$error=$http->SendRequest($arguments);
if($error=="") {
for( ; ; ) {
$error=$http->ReadReplyBody($body, 1000);
if($error!="" || strlen($body)==0)
break;
$buffer .= $body;
}
}
$http->Close();
}
return $buffer;
}
From these code i see that i get the entire page content (i see all of it into $body) but $buffer is still truncated at 1024 bytes, and id doesn't generate errors or warning.
Now, i know that in php strings doesn't have limit of size (excluding the limit imposed with memory_limit) so, what is happening here?
I have no clue and i cannot complete mine script, anyone could suggest me which could be the trouble?