outputting a new line

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
misfitxnet
Forum Newbie
Posts: 14
Joined: Mon May 11, 2009 8:40 am

outputting a new line

Post 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?
Last edited by Benjamin on Wed May 13, 2009 1:07 pm, edited 1 time in total.
Reason: Added [code=php] tags.
Defiline
Forum Commoner
Posts: 59
Joined: Tue May 05, 2009 5:34 pm

Re: outputting a new line

Post 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);
 
?>
Post Reply