Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP readfile adds content length to output

Tags:

php

readfile

I am using the PHP readfile function to read a file and print it like so: print readfile ('anyfile'). This works, but the content length of the file is added at the end of the string also. Why?

like image 642
SQLighter Avatar asked Apr 28 '10 21:04

SQLighter


1 Answers

readfile() prints out the contents itself and returns the content length -- you're effectively printing the contents with readfile and then printing the content length with print. Remove print and just use

readfile('anyfile');
like image 75
Andy E Avatar answered Sep 23 '22 18:09

Andy E