Jump to content

file_get_contents() Functionality...?


cyfer65
 Share

Recommended Posts

How come this will work...
<?phpecho file_get_contents('http://whatismyip.org/');?>

But this wont..?

<?phpecho file_get_contents('http://tinyurl.com/yardhc');?>

the tinyurl just forwards to http://whatismyip.org/why doesn't it follow through to the forwarded site to get its contents..?What else can i do to make it work using the tinyurl..?

That's because what tinyurl does is send a location header to the client which contains the URL that the client must redirec to. You would need to use cURL to read the response header and have your program use file_get_contents on the URL that's found in that header.
Link to comment
Share on other sites

Basically, file_get_contents() doesn't follow the redirect, like more advanced libraries such as cURL can.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...