Jump to content

file get contents


egturnkey

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.