Home Tutorial Php Phpfiles The PHP file_get_contents() function , file_get_contents php

 
 

The PHP file_get_contents() function , file_get_contents php
Posted on: September 24, 2009 at 12:00 AM
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

 

Related Tags for The PHP file_get_contents() function , file_get_contents php:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.