Results 1 to 5 of 5

Thread: Server-side includes in .php?

  1. #1
    Old school, like an old fool. Flying Mullet's Avatar
    Join Date
    Apr 2003
    Location
    Napping in a peach tree.
    Posts
    19,185
    Articles
    6
    Blog Entries
    7
    Contributions
    • Former Administrator
    • Former Cid's Knight
    • Former Senior Site Staff

    Default Server-side includes in .php?

    Is there a way to do simple server-side includes in a .php file similar to <i>&lt;!--#include virtual="header.txt" --></i> in .shtml?
    Figaro Castle

  2. #2
    Prinny God Recognized Member Endless's Avatar
    Join Date
    Aug 2000
    Location
    Prinny Moon
    Posts
    2,641
    Contributions
    • Former Cid's Knight

    Default

    include 'file.php';
    or
    require 'file.php';

    In both cases it reads and executes the file, but include generates warnings in case of errors, whereas require generates fatal errors.

    And then there is Death

  3. #3
    Old school, like an old fool. Flying Mullet's Avatar
    Join Date
    Apr 2003
    Location
    Napping in a peach tree.
    Posts
    19,185
    Articles
    6
    Blog Entries
    7
    Contributions
    • Former Administrator
    • Former Cid's Knight
    • Former Senior Site Staff

    Default

    Well now, let's not get too simple.

    Thanks, I'll try it out.
    Figaro Castle

  4. #4
    Ominous Wanderer Tech Admin Samuraid's Avatar
    Join Date
    Oct 2001
    Posts
    5,522

    Default

    There is a difference between the two, although subtle...
    include('file.txt') and require('file.txt') both include file.txt.
    But if file.txt does not exist, require() will stop the php page execution, but include() only throws a warning and continues page execution.

    Edit: oops, endless already said that...

  5. #5
    Old school, like an old fool. Flying Mullet's Avatar
    Join Date
    Apr 2003
    Location
    Napping in a peach tree.
    Posts
    19,185
    Articles
    6
    Blog Entries
    7
    Contributions
    • Former Administrator
    • Former Cid's Knight
    • Former Senior Site Staff

    Default

    I've tried both and see what you both mean.

    Ahh, so simple yet so effective. This is exactly what I needed. Thanks a lot.
    Figaro Castle

Posting Permissions

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