I'm trying to learn how to create files with PHP, but I can't seem to get it to work correctly. Can anyone tell me why this code fails to create a file called myfile.txt ? The first lines are the only important parts for debugging, I figure, since the file doesn't write out "Success" at all. Thanks!
$filename = "myfile.txt";
$resultfile = fopen($filename, 'w');
if ($resultfile) {
echo "Success";
}
$name1 = "Matt";
$name2 = "Aaron";
$name3 = "Louis";
$val1 = 19;
$val2 = 53;
$val3 = 62;
for ($c=1; $c<3; $c++) {
fwrite($resultfile, $name.$c);
fwrite($resultfile, "\t");
fwrite($resultfile, $val.$c);
fwrite($resultfile, "\n");
}
fclose($resultfile);