[SOLVED] possible to assign content of a file to a variable?
Posted: Mon Dec 22, 2003 7:05 pm
basically i want to be able to assign the text in a file(.txt or .html) to a variable in another file.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<?php
$pathToFile("files/aFile.txt");
ob_start();
readfile($pathToFile);
$contents=ob_get_contents();
ob_end_clean();
// $contents should now contain the contents of the file.
echo $contents;
?>