Home of web learners
www.webn3rd.com
PHP has function to manipulate file
Lets start:
<?php $file = "lipi.txt"; $filepointer = fopen( $file, "r" ); ?>
Here,you see that our file is lipi and it is a text file,so at first before working with file,we have to open it with fopen function and have to say which mode it is going to open,here r mode means read mode,so we can not write
There are many modes for opening a file
Now check file size:
<?php echo filesize($file); ?>
It show us the file size of the file
Now show the entire file in the text file as it contains string
<?php $file = "lipi.txt"; $filepointer = fopen($file, "r"); $content = fread($filepointer, filesize($file)); echo $content; ?>
Here,you see that we use fread function to get all contents from this file as first argument is filepointer and next is size of the file we want to read as here we want to get it all
webn3rd.com