Read and store entire file content

by kalai 2008-04-19 19:04:51

The file_get_contents() reads a file into a string.

This function is the preferred way to read the contents of a file into a string. Because it will use memory mapping techniques, if this is supported by the server, to enhance performance.
Syntax

file_get_contents(path,include_path,context,start,max_length)

File_Get_Contents () works the same as file () except it returns a string instead of an array. This function retrieves data from an external file and then puts it into a string for use.

Example

<?php
$filestring = file_get_contents($filename);
print $filestring;
?>

RESULT:

This is a test file with test text.

Tagged in:

1685
like
0
dislike
0
mail
flag

You must LOGIN to add comments
Naveenkumar

I think there some logic in the student speech.. I read this from another website and shared here.. I Dont know the student was EINSTEIN or not..