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 6382793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:34:07+00:00 2026-05-25T02:34:07+00:00

I am learning PHP, and I’m trying to make an application that has a

  • 0

I am learning PHP, and I’m trying to make an application that has a relationship with an external website.
I need to download it.
So I got this code:

$str = file_get_contents($url);

Which should return me the HTML contents of a website.
it works fine for most websites, but for a particular one – http://www.fxp.co.il – it shows crap.
What is the problem ? What can I do to fix it ?
Thank you !
enter image description here

  • 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-25T02:34:08+00:00Added an answer on May 25, 2026 at 2:34 am

    Well, you should actually inspect the response headers as they tell you about the encoding of the data returned file_get_contents.

    For example, if it’s gzip encoded, you need to uncompress it.

    Normally you won’t notice that because file_get_contents() sends a request in a way that the server knows that it does not support compression.

    However some servers just do not care and send you compressed responses anyway:

    <?php
    
    $url = 'http://www.fxp.co.il/';
    
    $buffer = file_get_contents($url);
    
    echo $url, '<hr>', '<pre>', implode("\n", $http_response_header), '</pre>';
    
    $bare = gzdecode($buffer);
    
    echo '<hr>', htmlspecialchars(substr($bare, 0, 256));
    

    Output:

    http://www.fxp.co.il/
    ------------------------------------------------------------
    HTTP/1.1 200 OK
    Server: nginx/0.7.67
    Date: Mon, 29 Aug 2011 19:19:55 GMT
    Content-Type: text/html; charset=UTF-8
    Connection: close
    Set-Cookie: bb_lastvisit=1314607056; expires=Tue, 28-Aug-2012 19:12:44 GMT; path=/
    Set-Cookie: bb_lastactivity=0; expires=Tue, 28-Aug-2012 19:12:44 GMT; path=/
    X-Accel-Expires: 600
    Cache-control: must-revalidate, post-check=0, pre-check=0
    Pragma: cache
    Vary: Accept-Encoding,User-Agent
    Content-Encoding: gzip
    Content-Length: 14170
    Expires: Tue, 24 Jan 1984 08:00:00 GMT
    X-Header: Boost Citrus 1.9
    Cache-Control: must-revalidate, post-check=0, pre-check=0
    ------------------------------------------------------------
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="rtl" lang="he"> <head> <meta http-equiv="Content-Type" content="text/html; charset
    

    Take care!

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

Sidebar

Related Questions

I am working on a small project for learning PHP better. This project has
So, I started learning PHP. It turned out that I need local server or
I am learning PHP and need to download the Apache server. I have a
I'm a student learning PHP. I basically make the stuff work, but never wondered
I'm learning PHP. The PHP has inline commands in HTML code to produce dynamic
I am learning php, trying to use the fopen() function. The php file I
i just got some more questions while learning PHP, does php implement any built
I am learning PHP and I am at this point learning how to validate
When I was learning PHP, I read somewhere that you should always use the
Right, day 8 learning php and I feel that I have tried to do

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.