note the following code $ops=array() $context = stream_context_create($opts); $site="http://www.example.com/aa.php"; set_time_limit(20); $result = @file_get_contents($site, false, $context); Code (markup): the above code will get the full contents of this page in $result variable >> but I want to get directly only header content of this page in order to peform more speed and less ammount transfere and because I don't need the full contents ,I just want contents in the <header>............</header> . I don't want to do any extract on the $result variable. are there any ideas ??
thank you for your replay. but this page I want to request has a $_POST and $_GET variables and I want to pass these variables to this page. I can't pass these variables to this page and request the results using fopen,fread and fgets functions. thank you any other ideas
sorry I was wrong and thank you it 's work http://php.net/manual/en/function.fopen.php I can pass variables to $_POST and $_GET using fgets , fopen,... thank you
You could use the php function get_headers: http://php.net/manual/en/function.get-headers.php This will give you header information like the title if you only needed information like that.
Yeah, I was just saying that if he was only looking for more specific information which may be available through the HTTP headers it's worth taking a look at. - BS
This should work: <?php $site="http://www.example.com/aa.php"; $file = file_get_contents($site); if(preg_match("/<head.*>(.*)<\/head>/smU", $file, $match)){ echo $match[1]; } else { echo "No match found"; } ?> PHP: