The PHP file_get_contents() function , file_get_contents php


 

The PHP file_get_contents() function , file_get_contents php

This given example program explains the usage of file_get_contents() function. The example program will show you the correct usage of file_get_contents() function.

This given example program explains the usage of file_get_contents() function. The example program will show you the correct usage of file_get_contents() function.

The PHP file_get_contents() Function

Function reads the content of the whole file to a string. This function is the best way to read the contents of a file. This method is preferred by the programmers as it uses less memory because of use of memory mapping techniques. The memory mapping techniques is supported by the servers. So, the use of file_get_contents() will make your program fast.

It reads the file using  the file handler given by the fopen(), fsockopen() functions

It then returns  file contents as String 

To show the contents of the file no need of loop

Syntax of file_get_contents() Function PHP

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

Code of file_get_contents() Function PHP

<?php

$string1=file_get_contents("c:/rose1/ram.txt");

echo $string1;

?>

Output

welcome to roseindia welcome to roseindia welcome to roseindia welcome to roseindia welcome to roseindia welcome to roseindia

 

Ads