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

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #241110

    Any difference between the 2?


    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.


    The main idea for my site is to not allow users to edit my data. The only thing I plan on having is cookies for user preferences; which involve cookies [that idea I am still not comprehending yet]. I was having an issue where all but 1 of the preferences were not active after changing from html to php; that was the initial post, but saw I failed to include the link to the js page in my <head>. Which made little sense since they all worked but the one without the link.

    I thought it may have had something to do with the include statement at first, since we are unable to delete the post I figured I may as well ask this particular question.

    I get the idea, sad thing is is not very useful as it lacks a lot of content, but has helped a few times.

    As far as cookies are concerned, I do have Bootstrap on my server, and know there is a cookies script, but still do not know how to configure that, is there a link you (or anyone) can post to help me understand cookies.

    The cookies, canonical links, and robots.txt are some of the things I was looking into, but did not really research in depth. I’m not too concerned about these at the moment as I still have hundreds of other things going on, and I need to setup my SQL database for the cookies {login} anyways…with that needs security [such as adding htmlspecialchars to any php page that relies on MySQL].

    I read something months ago on how users can change data in the URL when php get is used. I’m far from that right now, but always good to get ideas well before I need them. You people here are very experienced and enjoy hearing from you all. Too bad there aren’t more. The only thing I can do is offer advice, or point people in the right direction because many of the issues others have I had similar experiences. It’s hard to find work in web development when many ask applicants to have years of experience; and the person just graduated.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.