Hi can anyone tell me how to read entire contents of a file to a variable and echo it. like $var = readallthefilecontents echo $var
thanks IM
Have a look on the fgets function. Like this <?php $fd = fopen ("the_file_name", "r"); while (!feof($fd)) { $buffer = fgets($fd, 4096); echo $buffer; } fclose ($fd); ?>
Hope it helps
Thanks very much
Another useful function would be file_get_contents.
This page will tell you everything you need to know about file operations: http://www.php.net/manual/en/ref.filesystem.php .
An even better one would be readfile (), that one function reads the contents of the file and echos it 😃