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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:42:22+00:00 2026-05-16T14:42:22+00:00

How can I get the html source code of http://www.example-webpage.com/file.html without using file_get_contents() ?

  • 0

How can I get the html source code of http://www.example-webpage.com/file.html without using file_get_contents()?

I need to know this because on some webhosts allow_url_fopen is disabled so you can’t use file_get_contents(). Is it possible to get the html file’s source with cURL (if cURL support is enabled)? If so, how?
Thanks.

  • 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-16T14:42:23+00:00Added an answer on May 16, 2026 at 2:42 pm

    Try the following:

    $ch = curl_init("http://www.example-webpage.com/file.html");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
    $content = curl_exec($ch);
    curl_close($ch);
    

    I would only recommend this for small files. Big files are read as a whole and are likely to produce a memory error.


    EDIT: after some discussion in the comments we found out that the problem was that the server couldn’t resolve the host name and the page was in addition a HTTPS resource so here comes your temporary solution (until your server admin fixes the name resolving).

    what i did is just pinging graph.facebook.com to see the IP address, replace the host name with the IP address and instead specify the header manually. This however renders the SSL certificate invalid so we have to suppress peer verification.

    //$url = "https://graph.facebook.com/19165649929?fields=name";
    $url = "https://66.220.146.224/19165649929?fields=name";
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: graph.facebook.com'));
    $output = curl_exec($ch);
    curl_close($ch); 
    

    Keep in mind that the IP address might change and this is an error source. you should also do some error handling using curl_error();.

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

Sidebar

Ask A Question

Stats

  • Questions 513k
  • Answers 513k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can do this without bootstrapper, if you create embedded… May 16, 2026 at 5:50 pm
  • Editorial Team
    Editorial Team added an answer Assuming that you may well have additional columns to return...… May 16, 2026 at 5:50 pm
  • Editorial Team
    Editorial Team added an answer It's working with your solution: @In private Map<String, String> messages;… May 16, 2026 at 5:50 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

i'm supposed to write code which when given a text file (source code) as
How do I get the Silverlight Add-On for Visual Studio 2010? And where can
How can I get Dojo Dijits (1.5.0, currently) to work with XHTML as application/xml+xhtml?
I'm working on a website where users can create and save their own HTML
I am designing an html web page that mimics inline panes by defining this
Maybe you can help me with a problem I am having. The URL of
In the process of learning Django and Python. I can't make sense of this.
Here is a piece of code that I use to fetch a web page
<html> <head> <title>ADD URL Sources</title> </head> <body> <form action=Test1.jsp method=post> <br><br><select name=source onchange=> <option
I'm trying to implement an image zoom effect, a bit like how the zoom

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.