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

 
 

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

 

Advertisement

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


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: September 24, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com