Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5955543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:07:45+00:00 2026-05-22T18:07:45+00:00

This is very strange, on some pages it will return the HTML fine, others

  • 0

This is very strange, on some pages it will return the HTML fine, others it will add numbers to the beginning and end of the returned string ($out).

function lookupPage($page, $return = true) {
    $fp = fsockopen("127.0.0.1", 48580, $errno, $errstr, 5);        
    if (!$fp) {
        return false;
    }
    else {
        $out = "";
        $headers = "GET /" . $page . " HTTP/1.1\r\n";
        $headers .= "Host: www.site.com\r\n";
        $headers .= "Connection: Close\r\n\r\n";
        fwrite($fp, $headers);
        stream_set_timeout($fp, 300);
        $info = stream_get_meta_data($fp);
        while (!feof($fp) && !$info['timed_out'] && ($line = stream_get_line($fp, 1024)) !== false) {
            $info = stream_get_meta_data($fp);
            if ($return) $out .= $line;
        }
        fclose($fp);
        if (!$info['timed_out']) {
            if ($return) {
                $out = substr($out, strpos($out, "\r\n\r\n") + 4);
                return $out;
            }
            else {
                return true;
            }
        }
        else {
            return false;
        }
    }
}

e.g…

3565
<html>
<head>
...
</html>
0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:07:45+00:00Added an answer on May 22, 2026 at 6:07 pm

    It is called Chunked Transfer Encoding

    It is part of the HTTP 1.1 protocol and you’re decoding it in a HTTP 1.0 way. You can just check for the values and trim them if you want. They only show the length of the response so the browser knows it has the complete response.

    Also maybe look at file_get_contents

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I find this very strange, must be something I'm doing wrong, but still... I'm
This problem is very strange and I'm hoping someone can help me. For the
This is a very strange problem, and I just hope that I can clearly
it is very strange, because this error doesn't happen all the time... I have
I have this very strange issue with my MVC 2 project. Often times, I'll
I wrote some PHP code that will allow me to create an html dropdown
I'm getting some very strange date formatting issues in my Silverlight application. My local
This is a very strange problem. I've got a rails app in which I
This question is about a very strange behavior of web controls. Consider the following
All, Sorry - this is probably a very strange question. I'm working on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.