Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    •  
      CommentAuthorSpookyET
    • CommentTimeFeb 2nd 2006
     permalink
    Instead of using include() or require() in the HTML (I don't know where it is defined). I do stuff like this to work directly on the template:

    $footer_file = '../inc/footer.inc';
    $footer_file_handle = fopen($footer_file, 'r');
    $tpl_temp = fread($footer_file_handle, filesize($footer_file));
    $tpl_redir = str_replace('<ksu_footer>', $tpl_temp, $tpl_redir);
    fclose($footer_file_handle);

    I was wondering if this is bad and a resource hog. Does require() or include() cache the file, or does it do the same thing as I did above?
    •  
      CommentAuthornifkin
    • CommentTimeFeb 2nd 2006
     permalink
    Require or include would pull the file directly into place wherever you used the require or include statement and it wouldn't pull things into a variable like you're doing there. For what it looks like you're doing that looks like a decent way to handle it.
    • CommentAuthordhazard
    • CommentTimeFeb 8th 2006
     permalink
    What do you mean you dont know where it is defined?

    That seems like a lot of extra work to get around an include...

    - Jon
    • CommentAuthorSayian
    • CommentTimeFeb 9th 2006
     permalink
    Hello SpookyET,

    Please understand that using require_once() will be the best option for you in this case. require_once() will only include the file 1 time, and if it has previously been included (for some reason) then it will throw a fatal warning, alerting you to the line it was previously included in, so you can remove it.

    This ensures that the same file doesnt get included twice.

    Also, using require_once() instead of fopen, is MUCH faster, as require_once() uses highly optimzed C code, from the php core function library to include your files.

    - Sayian
    •  
      CommentAuthorSpookyET
    • CommentTimeFeb 12th 2006
     permalink
    Thank you. But, I can't use require_once() nor require due to the way the forum is designed. It has templates in tpl files. And it replaces place holders like I did above.
Add your comments
    Username Password
  • Format comments as (Help)