Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2005
    Posts
    68

    Unanswered: file_get_contents vs require

    i have several repeating regions that i have created simple templates for. as i understand it when i require this template the page stops compiling, goes and compiles the template, then starts over. i was wondering if file_get_contents (then running str_replace) would be cleaner?

  2. #2
    Join Date
    Jan 2005
    Posts
    68
    fyi i just benchmarked both approaches. i saved .00018 seconds on the page load using file_get_contents. it is nice to have the file in a string though, easier to manipulate.

  3. #3
    Join Date
    Feb 2002
    Location
    San Francisco, CA
    Posts
    441
    Cool, file_get_contents would not compile the code you are correct. Require would parse it, looking for code to compile.

    Have you tried using preg_replace, instead of str_replace - If I remember correctly its supposedly quicker, and also can cope with multiple search/replaces at once using arrays...might save some more time?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •