Page 1 of 1

outputting a new line

Posted: Wed May 13, 2009 6:03 am
by misfitxnet
How do I output a new line in php using
fwrite?

Code: Select all

 
$output = $name."\t".$comment."\t"."\n";
 
$fp = fopen("d:\hshome\c239198\local54memberforum.com\info.txt", "ab");
fwrite($fp, $output);
 
only outputs $name and $comment, with the \t as tabs but ignores the \t.
Any ideas?

Re: outputting a new line

Posted: Wed May 13, 2009 6:33 am
by Defiline

Code: Select all

<?php
 
error_reporting(E_ALL);
 
/**
 * Declaration of variables
 */
$name    = 'Apple';
$comment = 'Hello, World';
 
/**
 * Opening a file (append mode)
 */
$handle = fopen('add.txt', 'a+');
 
fwrite($handle, "{$name} has leaved a comment: {$comment}\t\n");
fclose($handle);
 
?>