Reading a file : fread « File Directory « PHP
- PHP
- File Directory
- fread
Reading a file
<html>
<head>
<title>Reading a file</title>
</head>
<body>
<?php
$filename = "data.txt";
$filesize = filesize($filename);
$file = fopen( $filename, "r" );
$text = fread( $file, $filesize );
fclose( $file );
echo( "File Size: $filesize bytes" );
echo( "<pre>$text</pre>" );
?>
</body>
</html>
Related examples in the same category