NYCPHP Meetup

NYPHP.org

[nycphp-talk] How do you strip Header Info from displaying on your browser?

David Sklar sklar at sklar.com
Thu Oct 3 11:41:13 EDT 2002


If you *must* continue to use this WebGet() function, process the return
value like this:

$r = WebGet('www.sklar.com');
list($headers,$body) = explode("\\r\
\\r\
",$r);
print $body;

Each header ends with "\\r\
" and the headers and the body are separated with
a blank line, so "\\r\
\\r\
" delimits the headers and the body.

If you can use the Curl extension, try that, it's much easier:

$c = curl_init('http://www.sklar.com/');
curl_setopt($c, CURLOPT_RETURNTRANSFER);
$body = curl_exec($c);
curl_close($c);

Or you can use the HTTP_Request PEAR module, available at:
--> http://pear.php.net/package-info.php?pacid=33

-dave


> -----Original Message-----
> From: Phil Powell [mailto:soazine at erols.com]
> Sent: Thursday, October 03, 2002 12:27 AM
> To: NYPHP Talk
> Subject: [nycphp-talk] How do you strip Header Info from displaying on
> your browser?
>
>
> If you go to http://valsignalandet.com/feedback.php you can get a
> clearer indication of what I am trying to get rid of.  Following
> is my function using to produce the stuff up there, which I don't
> want, instead, I either want cookie-driven information or nothing
> (if no cookie is set):
>
> function WebGet($address, $port = 80, $url = '/', $post = false,
> $cookie = false) {
>    // Use fsockopen to catch the URL
>    $fp = fsockopen ( $address, $port);
>
>    // Zero Fill
>    $ret = '';
>
>    if ($fp) {
>       // Success.  Now check to see the type of request
>       if ($post) {
>          $request = "POST $url HTTP/1.1\
";
>          $request .= "Host: $address\
";
>          $request .= "Content-Length: " . strlen( $post ). "\
";
>          $request .= "Content-Type: application/x-www-form-urlencoded\
";
>
>          if ($cookie) $request .= "Cookie: $cookie\
";
>
>          $request .= "Connection: Close\
\
";
>          $request .= $post;
>       } else {
>          $request = "GET $url HTTP/1.1\
";
>          $request .= "Host: $address\
";
>          $request .= "Content-Type: text/html\
";
>
>          if ($cookie) $request .= "Cookie: $cookie\
";
>
>          $request .= "Connection: Close\
\
";
>       }
>
>       $ret = '';
>
>       // Write the Request
>       fputs ($fp, $request);
>
>       // Get the response
>       while (!feof($fp)) $ret .= fgets ( $fp, 128 );
>
>       // close the connection
>       fclose ($fp);
>    }
>
>    return $ret;
>
>  }
>
> I do not want to change WebGet as I wish to keep it a universal
> function that can be used for cookies or not.
>
> So, how can I get rid of the trash on my page?
>
> Thanx
> Phil
>
>
>
> --- Unsubscribe at http://nyphp.org/list ---
>




More information about the talk mailing list