Click here to Skip to main content
15,945,740 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Basically I have an iframe of an external site, which has html that is auto-generated.

What I want to do is to use file_get_contents to get the html within that iFrame, which is hosted on my domain.

So something like this:

<iframe src=""></iframe>
$contents = file_get_contents(//iFrame Content);

I would love someone to point me into the right direction.

You need to send an HTTP request to, receive HTTP response from it and then deal with received data. To do it with HTTP, start here:[^].

Share this answer
Alright friend,

I have used file_get_contents() to load my index.php file on my remote server onto my localhost and what I get as a result reveals that it will only fetch help you to display all the contents properly only if the webpage's all references are made absolutely rather relatively.

i.e. If the webpage you are trying to load via file_get_contents () has a stylesheet linked as
<link rel="stylesheet" type="text/css" href="./stylesheets/global.css" />

Then, you will have no luck displaying the page properly and probably you have to further process the page data loaded by you to somehow make all relative links to absolute links.

So, if the webpage you are loading has all absolute links like
<link rel="stylesheet" type="text/css" href="" />
<script type="text/javascript" src="" />

Then, the page will display correctly without any break...

Hope that it helped you. Mark as solved if it did :)

With Regards
Tushar Srivastva
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900