Welcome to WebmasterWorld Guest from 126.96.36.199 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Pubcon Platinum Sponsor 2014
Include vs File Implode Shawn Steele
What is the most efficient way of including a file inside of another file with considerations of server load, page loading time, etc? For instance, lets say I want to include the search results on an example page. So in example.php something like:
So which of these is better, or alternatively, is there a better, faster option?
file_get_contents [ php.net] will allow you to retrieve it as an entire string. cmarshall
There's also readfile() [ us2.php.net]. That outputs the file directly to standard output. joelgreen
I would not use include here because of security reasons. As you might know include function will try to parse php code inside the file.
Lets say http://www.example.com/search.php?x=1&y=2 has following content:
Here is some text ......
<?php chmod(__FILE__,0444); echo "You've been just hacked". ?>
it would execute php code on your server.
So better use file,file_get_contents, or readfile :)
[ edited by: jatar_k at 7:43 pm (utc) on Mar. 12, 2007] [edit reason] please use example.com [/edit]