PHP - How do you write a function to a text file?
I'm trying to figure out how to write the output of a custom function to a text file, but there must be something I don't understand about the relationship between functions and writing to a file.
Here's an example of what I'm trying to do...
<?php
function test_function ()
{
echo "Hello!";
}
$function_contents = test_function ();
$file_name = "test_file.txt";
$file_handle = fopen($file_name, 'w');
fwrite($file_handle, $function_contents);
fclose($file_handle);
?>
When I run this script, the text file it creates is blank.
Any idea what I'm missing here?
-
aesoft -
[ 1 ] Thanks - 1 reply
{{ DiscussionBoard.errors[3001373].message }}-
Brandon Tanner -
Thanks
Signature{{ DiscussionBoard.errors[3001413].message }} -
-