egturnkey Posted October 3, 2010 Share Posted October 3, 2010 Hello friends, if i have the following $path = "http://*site*.com"; why can't i write the following $ORGtext= file_get_contents('$path'); it works only if i write $ORGtext= file_get_contents('http://*site*.com'); but i want to put $path instead of the url at file_get_contents is it possible and if yes then how ? thank you Link to comment https://forums.phpfreaks.com/topic/215037-file-get-contents/ Share on other sites More sharing options...
Yesideez Posted October 3, 2010 Share Posted October 3, 2010 If you place a variable inside single quotes you'll get the name of the variable (ie. exact text) and not the contents. Try this: $ORGtext= file_get_contents($path); You can place variables inside double quotes and get their contents - this is the difference between single and double quotes. Link to comment https://forums.phpfreaks.com/topic/215037-file-get-contents/#findComment-1118521 Share on other sites More sharing options...
PaulRyan Posted October 3, 2010 Share Posted October 3, 2010 Try the following egturnkey... $ORGtext= file_get_contents($path); Or this... $ORGtext= file_get_contents(''.$path.''); They both retrieve same data, except the first one is just using the variable as the string while the second one is concating the variable into a string. Regards, Paul. Edit* Seems we posted at the same time, use which feels more comfortable Link to comment https://forums.phpfreaks.com/topic/215037-file-get-contents/#findComment-1118522 Share on other sites More sharing options...
egturnkey Posted October 3, 2010 Author Share Posted October 3, 2010 thank you both it is working now perfect Link to comment https://forums.phpfreaks.com/topic/215037-file-get-contents/#findComment-1118524 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.