Solved hello

Solved issue


It is missing the opening and closing tags at the beginning and end of the file. If you add them, it will run.

Code:
<?php
$file=fopen("filename.txt","w");
$writing="hello, there\n";
fwrite($file,$writing);
fclose($file);
?>

Code:
$ ls
dofile.php
$ php dofile.php
$ ls
dofile.php  filename.txt
$ cat filename.txt
hello, there
$

I called my php file "dofile.php". I added a "newline" character to the end of the string, so that after you type "cat filename.txt", the prompt appears at the beginning of the next line. Try it both ways - with the newline \n and without it.

(P.S. If that answers your question, please click the Edit link at the bottom of your original post at the top of this thread. Change the Title prefix to "Solved".)
 
Last edited:

Members online


Top