View Full Version : Saving with variables

11-09-2007, 10:23 PM
Ok i'm using php to save a webpage to the webserver. The saved file's name is supposed to be equal to the variable $uic I can't get it to display the value of $uic

heres the code:

$return = file_put_contents('../../../archives/docs/account_details/$uic.txt', $content);

that saves the file called $uic.txt instead of printing: 7706869110330709208613965.txt

does anybody know how i can fix this?

11-09-2007, 10:25 PM
when i make the code like this:

$return = file_put_contents('../../../archives/docs/account_details/'$uic.txt', $content);

i get this error message:

Parse error: syntax error, unexpected T_VARIABLE

11-09-2007, 10:29 PM
You might want to buy a PHP book.

You have to concatenate strings with variables using the concatenation operator.

$return = file_put_contents('../../../archives/docs/account_details/' . $uic.txt', $content);

Notice the period?

$return = file_put_contents('../../../archives/docs/account_details/$uic.txt', $content);

PHP does not parse single quoted strings for variables.

$return = file_put_contents("../../../archives/docs/account_details/$uic.txt", $content);