Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End include vs file_get_contents Reply To: include vs file_get_contents

#241111
Beverleyh
Participant

include() allows the execution of functions/code from with the included file.

file_get_content() interprets the incoming content as a string. Any code inside won’t be executed.

Usage depends on what you’re trying to achieve. For static data (like records from a txt/csv file), or user generated content or files that are writable, file_get_content() is the safer way to incorporate them. But if you want to pull in variables or code that can execute (like a config or plugin file), an include() is the way to go.