Page 1 of 1

[SOLVED] possible to assign content of a file to a variable?

Posted: Mon Dec 22, 2003 7:05 pm
by karlo_ubc
basically i want to be able to assign the text in a file(.txt or .html) to a variable in another file.

Posted: Mon Dec 22, 2003 7:09 pm
by Gen-ik
Try this...

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;

?>

Posted: Mon Dec 22, 2003 7:33 pm
by karlo_ubc
thanks Gen-ik, worked perfect