Results 1 to 2 of 2

Thread: Php question -> Include & require vs header

  1. #1
    Join Date
    Mar 2007
    Posts
    6

    Php question -> Include & require vs header

    So I am building a database driven, dynamic web page, and I only have a small grasp on PHP. Most of my scripts are separate and are called as needed.

    In many of the examples I have seen, the script uses a header( blahblah.php) or some such, which I'm not sure I understand the difference between includes/requires and these headers.

    Can anybody explain this to me in simple terms? The PhP manual online doesn't clarify it for me.

  2. #2
    Join Date
    Feb 2007
    Location
    Ireland
    Posts
    1,007
    It's quite simple actually.

    include("file.php");

    This will include the file into the page. If the file isn't there, it will ignore it and continue to load the rest of the page.

    require("file.php");

    This will insert the file into the page, exactly the same as the include function. However, if the file doesn't exist. It will cause an error and kill the page, so nothing will be loaded.

    As for the header function. This sends HTTP request headers to the server. This can be used to specify where you would like the browser to go, or what format the content of the page will be displayed in... such as html, plaint text or an image etc... or control the cache etc...

    It has many uses. You should google them to find out more.

Posting Permissions

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