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. 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? 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. 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. 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. 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
Archived
This topic is now archived and is closed to further replies.