greenheart Posted October 8, 2009 Share Posted October 8, 2009 Hello, is there a way around the fact that file_get_contents doesn't take a variable? For example, the below doesn't work $link = "http://www.example.com"; $contents = file_get_contents($link); echo $contents; but $contents = file_get_contents('http://www.example.com'); echo $contents; does. Please advise me on this. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/176956-file_get_contents-doesnt-take-a-variable/ Share on other sites More sharing options...
Garethp Posted October 8, 2009 Share Posted October 8, 2009 The first code worked for me. What's your error? Quote Link to comment https://forums.phpfreaks.com/topic/176956-file_get_contents-doesnt-take-a-variable/#findComment-933010 Share on other sites More sharing options...
PFMaBiSmAd Posted October 8, 2009 Share Posted October 8, 2009 file_get_contents($link); is valid, assuming that is an accurate representation of your actual code, because if it had single-quotes around $link, it would not work. Quote Link to comment https://forums.phpfreaks.com/topic/176956-file_get_contents-doesnt-take-a-variable/#findComment-933014 Share on other sites More sharing options...
greenheart Posted October 8, 2009 Author Share Posted October 8, 2009 That's weird, I tried that ten times last night and it was giving me an error and now it works, I must have had something obvious slightly wrong. I'm going to re-check a few things and see if I can get the error I was having to appear again. Quote Link to comment https://forums.phpfreaks.com/topic/176956-file_get_contents-doesnt-take-a-variable/#findComment-933036 Share on other sites More sharing options...
PFMaBiSmAd Posted October 8, 2009 Share Posted October 8, 2009 Posting actual error messages is the quickest way of getting a solution to what is causing an error. Quote Link to comment https://forums.phpfreaks.com/topic/176956-file_get_contents-doesnt-take-a-variable/#findComment-933039 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.