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

  • Home
  • SEARCH
  • 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 5940019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:54:35+00:00 2026-05-22T15:54:35+00:00

I’m building a script to check whether sites are up or not by reading

  • 0

I’m building a script to check whether sites are up or not by reading a given page’s content and looking for a predefined string in it (if the site is down the string won’t be found).

I’m reading a page content with the function file_get_contents, the problem is that at some rare cases the content received is simply Gibberish. I tried to do the same with fopen and even with curl. Getting gibberish with all functions. At the beginning I thought its because of encoding issues (the pages are UTF8) and I tried to play with all the parameters, but it doesn’t seem to be it.

The whole thing became much weirder when I decided to test the code on another server. It worked perfectly! the same pages which return gibberish on my dev station return readable text when being run on my other web server.

Both stations have the latest WAMP installed as a dev environment, do you have any suggestions to what can cause this?

  • 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-22T15:54:36+00:00Added an answer on May 22, 2026 at 3:54 pm

    as i said it could be a gzipped output, use this function and pass that “gibberish” through it. if its not the issue let me know ill remove this answer

    $site = file_get_contents('http://example.com');
    echo gzdecoder($site);
    
    function gzdecoder($d){
        $f=ord(substr($d,3,1));
        $h=10;$e=0;
        if($f&4){
            $e=unpack('v',substr($d,10,2));
            $e=$e[1];$h+=2+$e;
        }
        if($f&8){
            $h=strpos($d,chr(0),$h)+1;
        }
        if($f&16){
            $h=strpos($d,chr(0),$h)+1;
        }
        if($f&2){
            $h+=2;
        }
        $u = gzinflate(substr($d,$h));
        if($u===FALSE){
            $u=$d;
        }
        return $u;
    }
    

    EDIT:

    not sure, odd settings. ive run into this problem before with some sites

    SetEnv no-gzip dont-vary in a .htaccess file turns it off

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,

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.