Page 1 of 1

Using fwrite with variables attached

Posted: Mon Apr 02, 2007 9:48 am
by lunny
Hi,

I am trying work with fwrite() to write some information to a seperate URL from a php page. I am trying to send a variable with some data but this isnt working for me.

For example

$fp = fopen($filename, 'w+');
fwrite($fp,"<?php
$test = 'Hello';
?>");

It doesnt work I get parse errors any ideas why ?

Posted: Mon Apr 02, 2007 9:56 am
by Kieran Huggins
assign the var with a heredoc then write the var?

Posted: Mon Apr 02, 2007 10:07 am
by feyd
Double quote string and variables not escaped.

Posted: Mon Apr 02, 2007 10:32 am
by lunny
can you expand on what you mean by that please? - double quote strings and variables not escaped??? perhaps an example.. thank you..

Posted: Mon Apr 02, 2007 10:35 am
by Oren
He means that this:

"<?php $test = 'Hello'; ?>"

should be:

"<?php \$test = 'Hello'; ?>"