PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 307,137 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,827 people online right now. Registration is fast and FREE... Join Now!




File

 

File

fig79

7 Nov, 2009 - 07:25 AM
Post #1

D.I.C Head
**

Joined: 25 Feb, 2009
Posts: 50


My Contributions
CODE
<?php

    function writeMe($myFile) {
        $fHandle = fopen("$myFile",'w') or die ("Failed");
        $string = "Hi";
        fwrite($fHandle, $string);    
        $string = "John";
        fwrite($fHandle, $string);
        fclose($fHandle);
    }
    
    $myFile = 'Test.txt';
    writeMe($myFile);
    
?>


This program's output is :
HiJohn

but I want the output like this :
Hi
John

How?

User is offlineProfile CardPM
+Quote Post


William_Wilson

RE: File

7 Nov, 2009 - 07:28 AM
Post #2

lost in compilation
Group Icon

Joined: 23 Dec, 2005
Posts: 4,668



Thanked: 97 times
Dream Kudos: 3275
Expert In: Java, C, Javascript

My Contributions
the new line character is represented as \n you can add it to another string or output it individually.

Ex:
CODE

//one way
$string = "Hi\n";
fwrite($fHandle, $string);

//another way
$string = "Hi";
fwrite($fHandle, $string);
$string = "\n";
fwrite($fHandle, $string);

User is offlineProfile CardPM
+Quote Post

fig79

RE: File

7 Nov, 2009 - 07:40 AM
Post #3

D.I.C Head
**

Joined: 25 Feb, 2009
Posts: 50


My Contributions
QUOTE(William_Wilson @ 7 Nov, 2009 - 07:28 AM) *

the new line character is represented as \n you can add it to another string or output it individually.

Ex:
CODE

//one way
$string = "Hi\n";
fwrite($fHandle, $string);

//another way
$string = "Hi";
fwrite($fHandle, $string);
$string = "\n";
fwrite($fHandle, $string);



It`s not working!
By the way, I bought my laptop in Japan.
If I press "\n" the output is like japanese's money sign.

is there another way?
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 03:10PM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month