Try this sample code I threw together to illustrate a point:
<?php
$url = "http://www.amazon.com/gp/offer-listing/B003WSNV4E/";
$html = file_get_contents($url);
echo($html);
?>
The amazon homepage works fine using this method (it is echoed in the browser), but this page just doesn’t output anything. Is there a reason for this, and how can I fix it?
I think your problem is that you’re misunderstanding your own code.
You made this comment on the question (emphasis mine):
This implies to me that an Amazon page is appearing in your browser when you run this code. This is entirely expected.
When you try to download
https://rads.stackoverflow.com/amzn/click/B003WSNV4E, you’re being redirected tohttps://www.amazon.com/gp/offer-listing/B003WSNV4E/ref=dp_olp_new?ie=UTF8&condition=newwhich is the intent of StackOverflow’s RADS system.What happens from there is your code is loading the raw HTML into your
$htmlvariable and dumping it straight to the browser. Because you’re passing raw HTML to the browser, the browser is interpreting it as such, and it tries (and succeeds) in rendering the page.If you just want to see the code, but not render it, then you need to convert it into html entities first: