Jump to content

Little php help


php-n00b

Recommended Posts

Welcome to the PHP world. Please be more descriptive in the future though and google is your friend. It's a generous morning though, so:

<?php
$file = "testfile.txt";
$fh = fopen($file, 'w') or die("Unable to Open");
$data = "Input Goes Here";
fwrite($fh, $data);
fclose($fh);
?>

 

That will open testfile.txt or create it if it doesn't exist and write $data to it. The "w" portion in the fopen means it will overwrite anything already in there. This will be putting it in the same directory of the page that's running it.

Link to comment
https://forums.phpfreaks.com/topic/146705-little-php-help/#findComment-770228
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.