PHP Create text file
OK Guys I am an ASP guy.
I need to write a file in PHP.
The file needs to be an XML document. In ASP I just create a FileSystem Object and call the writeline method.
How would I write this in PHP?
Thanks,
Mike
Blessed is the man who fears the LORD, who delights greatly in his commandments. Psalms 112:1
Mark Hensler posted this at 23:56 — 26th May 2003.
He has: 4,048 posts
Joined: Aug 2000
The PHP equivalent to ASP's filesystem:
http://us4.php.net/manual/en/ref.filesystem.php
<?php
$fp = fopen(\"/path/to/file.txt\", 'w+');
// or
//$fp = fopen(\"c:\path\to\file.txt\", 'w+');
if ($fp) {
fwrite($fp, \"<test1></test1>\");
fwrite($fp, \"<test2></test2>\");
close($fp);
}
?>
Mark Hensler
If there is no answer on Google, then there is no question.
necrotic posted this at 00:40 — 29th May 2003.
He has: 296 posts
Joined: May 2002
I believe you have to add \n after the first entry. Not sure myself, either.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.