Actually after executing your function, the
echo $str;
prints only a number 1...
so there should be something wrong...
Main Topics
Browse All TopicsHello,
I'm struggling with this problem.
I have a basic index.php page containing an iframe:
I would need somehow to get access the html code of the page in the iframe.
I tried fopen() and file_get_contents(), but they return browser not supported error.
I tried with this script but it asks the user to login again, also if there is a session open. Anyway if the user login the second time that it return error cause your browser does not support cookies...
Is there any way to do this?
Thank you
BR
D.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi elvin66,
thank you for your code.
As I described in my question, I already tried the function file_get_contents() and it return an error that says that the browser is not supported.
I also tried again your code just to make sure and if I execute at the end of your code 'echo $contents' that should show the full page... it's again the same problem...
The html of an error page is stored in $contents.
There is nothing wrong with my browser. If I open the page is http://www.domain.com/page
It's clear that this doesn't depend on the browser but on http://www.domain.com/page
file_get_contents('http://
I assume by that comment that you have tried EVERY browser yes???
Wrong. I just tried the code I gave you and it works in Opera and Firefox so it IS something to do with your browser.
There is nothing wrong with that url you supplied. I have attached the exact code I just used to test it just in case there was some problem with the copy/paste or you did not copy my other code. Please try once again if you want to.
If it's a browser problem, why if I use Safari, Firefox or Opera to connect http://www.domain.com/page
I do not know, but like I said, I have Firefox 3.5 and Opera 10.01 and Epiphany 2.26.1 and it works great in all 3 browsers. Can you try using a different machine perhaps? Another thing that is possible is maybe a setting on your server or something. Are you using a localhost server on your Pc ?
I know some service providers do not allow the use of "file_get_contents();" and they block it. I have uploaded my script to one of my online servers. Please try it at this link
http://www.junktraders.co.
If it still does not work, then it is a problem on your machine, if not, it's a problem with your server. Let me know the results.
What? No you can't lol. You are seeing the page that you game me the URL for "http://www.domain.com/pag
So, it's working then yes?
Business Accounts
Answer for Membership
by: elvin66Posted on 2009-11-08 at 17:01:58ID: 25772822
The simple way is like this:
);
$str = file_get_contents($url); // as you already know the url inside the Iframe
Problem is some servers block that method so you could try a similar function to the one you have above. This should work:
function get_url_contents($url){
$crl = curl_init();
$timeout = 5;
curl_setopt ($crl, CURLOPT_URL,$url);
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
$ret = curl_exec($crl);
curl_close($crl);
return $ret;
}
// useage eg: your webpage url might be $web_page
$str = get_url_contents($web_page
// now you have the html content in a string variable.