0

Hello, I am new here, and hope to learn and contribute a lot. Recently, I started learning PHP (about 2 weeks), and now I am coming to the fopen() function. Say that I wanted to create a new file for reading and writing, is this what I would do?

$newfile = fopen("http://www.mydomain.org/php/Practice/text.txt", "a+");

Thanks in advance for any help,
Philip

3
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by phouse512
0

Ok, sorry for the double post, but I think I got it right. Here is the code to open, write, and close a new file I have:

<?php

$newfile = fopen("http://mydomain.org/php/Practice/mydata.txt", "a+");

fwrite($newfile, "This is a new file.");

fclose($newfile);

echo "All done!";

?>

Is that right? And if it is, how do I know if it worked, because when I run it, I can't find that new file on my server

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.