Hello my firends
PHP Code:<?php
/* Open a test file for writing */
$fp = fopen("test.txt", "w+");
/* Apply the ROT13 filter to the
* write filter chain, but not the
* read filter chain */
stream_filter_append($fp, "string.rot13",
STREAM_FILTER_WRITE);
/* Write a simple string to the file
* it will be ROT13 transformed at the end of the
stream operation
* way out */
fwrite($fp, "This is a test\n"); // string data is
//first written, then ROT13 tranformed and lastly
//written to file*/
/* Back up to the beginning of the file */
rewind($fp);
$contents=fread($fp,512);
readfile("test.txt");
fclose($fp);
echo $contents;
?>
The output is:
Guvf vf n grfg
This is a test
When we use readfile(),It prints:
Guvf vf n grfg
But,When we use fread(),It prints:
This is a test
Why?





Bookmarks