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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.