Results 1 to 2 of 2
Whats wrong with this code
Code:
<html>
<body>
<?php
$file = fopen("test.txt","a");
echo fwrite($file,$_POST["name"] . "<br />");
echo fwrite($file,$_POST["age"] . "<br />");
fclose($file);
?>
</body>
</html>
its not skipping a ...
- 07-08-2007 #1Just Joined!
- Join Date
- Aug 2005
- Posts
- 54
PHP: Skipping Lines
Whats wrong with this code
its not skipping a line....Code:<html> <body> <?php $file = fopen("test.txt","a"); echo fwrite($file,$_POST["name"] . "<br />"); echo fwrite($file,$_POST["age"] . "<br />"); fclose($file); ?> </body> </html>
its like nameagenameage
- 07-09-2007 #2
You mean in text.txt?
This is correct behavior. test.txt should look like:
The reason for this is that fwrite() simply writes the given string to the given file. It differentiates lines by using the newline character "\n", not the HTML line break.Code:Alex<br />19<br />
Try replacing the "<br />" with "\n".
Having said all that, the example you've given makes little sense. Since fwrite() just returns the number of bytes written, you're going to end up with a page that just has two numbers on it.DISTRO=Arch
Registered Linux User #388732


Reply With Quote