Share on Google+Share on Google+

Example of fgetc in PHP, fgetc php, fgetc in php

Advertisement
In this PHP tutorial section you will learn the use of fgetc() function in php.

Learn how to use the fgetc() function in PHP programming.

Syntax

string fgetc ( $file_handler )

It gives a character by character by using the file handler returned by fopen() and fsockopen() function

The string returned is displayed as the content

It is used with feof() function in loops

It is basically used to display the content of the file

Some functions based on character  can be used while getting character  inside the loop

For example @sign,© sign, .sign etc.

Here users have to give the new line character 

If <Br> is used then result will be one character in single line

Code for PHP fgetc() Function

<?php

$file1=fopen("c:/rose1/ram.txt","r");

for (;!feof($file1);)

{

$c=fgetc($file1);

echo $c;

}

?>

Output

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

 

Advertisements

Posted on: September 22, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.