# Problem with file\_get\_contents()

**URL:** https://forum.kirupa.com/t/problem-with-file-get-contents/237034
**Category:** Uncategorized
**Created:** [August 26, 2007, 6:12pm UTC](https://forum.kirupa.com/t/problem-with-file-get-contents/237034 "2007-08-26T18:12:19Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![zero\_one1](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/zero_one1/32/948_2.png) [@zero\_one1](https://forum.kirupa.com/u/zero_one1)
#### Post date: [August 26, 2007, 6:12pm UTC](https://forum.kirupa.com/t/problem-with-file-get-contents/237034/1 "2007-08-26T18:12:19Z")

</div>

I have an PHP application which get the source code of HTML pages.  
You input the URL and the source code is returned, but some sites are returning an error from file\_get\_contents() …

**Warning** : file\_get\_contents([http://en.wikipedia.org/wiki/Main\_Page](http://en.wikipedia.org/wiki/Main_Page)) [[function.file-get-contents](http://www.matthewzammit.com/htmlparser/03/function.file-get-contents)]: failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in **/home/content/m/a/t/matthewzammit/html/htmlparser/03/evaluate.php** on line **442**  
[FONT=Arial]

[SIZE=2]line 442 is where the URL is read:

```auto
$htmlText = file_get_contents($url);

```

[/SIZE]

[SIZE=2]but when the error is return $htmlText remains empty

two sites which return this error are:

> **[Main Page](https://en.wikipedia.org/wiki/Main_Page)**
>
> The sinking of the RMS Titanic in the early morning of 15 April 1912, four days into the ship's maiden voyage from Southampton to New York City, was one of the deadliest peacetime maritime disasters in history, killing more than 1,500 people. The largest passenger liner in service at the time, Titanic had an estimated 2,224 people on board when she struck an iceberg in the North Atlantic. The ship had received six warnings of sea ice but was travelling at near maximum speed when the lookouts sigh...

  
[http://www.petsmart.com](http://www.petsmart.com)

and when using https:// sites, my parser keeps reading but returns nothing, not even an error:

> **[Bank of America - Banking, Credit Cards, Home Loans and Auto Loans](https://www.bankofamerica.com)**
>
> Welcome to Bank of America, home for all of your financial needs. Our purpose is to help make financial lives better through the power of every connection.

  

> **[Send Money, Pay Online or Set Up a Merchant Account - PayPal](https://www.paypal.com/us/home)**
>
> PayPal is the faster, safer way to send money, make an online payment, receive money or set up a merchant account.

any help is appreciated, or links for further reading, as I can’t find anything which is actually related.

thanks.  
[/SIZE][/FONT]
