Page 1 of 1
unexpected variable?
Posted: Fri Feb 20, 2004 2:14 pm
by defx
Code: Select all
function submit()
{
$outputstring = "test"
$fp = fopen("$file", "w");
fwrite($fp, $outputstring);}
}
Parse error: parse error, unexpected T_VARIABLE on line 27
Line 27 = closing bracket for function submit
Also, is it possible to write variables using fopen and fwrite? for example I want to write into a PHP file, $var1 = "variable 1"; how would I do that?
Posted: Fri Feb 20, 2004 10:07 pm
by EvilWalrus
Code: Select all
<?php
function submit($file)
{
$outputstring = "test";
$fp = fopen($file, "w");
fwrite($fp, $outputstring);
}
submit('this_is_a_file.txt');
?>
Posted: Fri Feb 20, 2004 10:16 pm
by Illusionist
the only thing wrong int hat is you missed a semi-colon (;) at teh end of the $outputstring line.
And yes you can write to a PHP file. do it the same way:
But oyu would first have to parse throught he PHP file and add it where you wanted... not as easy as you want it to be!