PHP Exercises: Get the size of a file
PHP: Exercise-39 with Solution
Write a PHP program to get the size of a file.
Sample Solution: -
<?php $myfile = fopen("/home/students/ppp.txt", "w") or die("Unable to open file!"); $txt = "PHP Exercises\n"; fwrite($myfile, $txt); $txt = "from\n"; fwrite($myfile, $txt); $txt = "w3resource\n"; fwrite($myfile, $txt); fclose($myfile); echo "Size of the file: ".filesize("/home/students/ppp.txt")."\n"; ?>
Size of the file: 30
PHP Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?