Page 1 of 1

include/require vs. readfile

Posted: Fri Nov 22, 2002 1:26 pm
by ruthsimon
Most reference books/posts/documentation/etc. recommend using include() or require() to add, say, a common header to multiple php pages.

What's wrong with using readfile()?

Thanks, Ruth

Posted: Fri Nov 22, 2002 1:46 pm
by Xelmepa
I guess the authors know more than us, but taking a quick glance at readfile's documentation:

Description
int readfile ( string filename [, int use_include_path])


Reads a file and writes it to the output buffer.

Returns the number of bytes read from the file.

We see that readfile also returns filesize, which we usually don't need, therefore becoming slower than include. But I bet there's more to it.

Posted: Fri Nov 22, 2002 5:22 pm
by mydimension
well readfile is a viable solution, if the file your are reading from is strictly html with no php scripting in it. if you want to include a file with php script then you must use include and/or require