Web Hosting Talk







View Full Version : fwrite problem!


UrlGuy
06-25-2005, 05:59 PM
Hi,
I have this PHP file, with the below code what it does is
it makes another file named members.php and puts this in it:
<?PHP echo "hi"; ?>
But I want it to put this into it instead:
<?PHP
echo "hi";
?>
so pretty much the same only with new lines
but when I make another of this like
$stuff .= "\n";
or
$stuff .= "<BR>";
It just puts the <BR> or \n into the PHP file, and not making spaces but just directly puts it in..

Anyone know how I can make spaces in it?? Thx in advance!!


$stuff = "<?PHP";
$stuff .= " echo 'hi';";
$stuff .= "?>";

$file = fopen("members.php", 'a');
fwrite($file, $stuff);
fclose($file);



The thing is.. I made this login system for this dude.. pretty simple stuff, but now he want me to fix it so each member can edit their profile, like addinig their name, adress, phone etc.
I plan to just write all this info to a PHP file using the switch statement. So when a user is logged on, lets say user "johndoe" in his membersarea it can be a link "edit profiile" which is a hyperlink to members.php?member=johndoe which takes him to the area with his info.. but I need to be able to have fwrite write the whole switch statement, and add new ones as they sign up. Thats why I cant have one long line, but need to make new lines but if I do $stuff .= "<BR>"; then <BR> is just written in the middle of the PHP file instead of making it a space..

xelav
06-26-2005, 06:38 AM
Try

$stuff=<<<EOT
<?PHP
echo "hi";
?>
EOT;
$file = fopen("members.php", 'a');
fwrite($file, $stuff);
fclose($file);