Results 1 to 10 of 10

Thread: Include Files In PHP?

  1. #1
    Member
    Join Date
    Jun 2002
    Posts
    95

    Include Files In PHP?

    Hello my nerdy amegos ,

    Is there a method of putting include files in PHP. For example, in ASP they do it like this :: <!- #include file="thepage.asp" ->.

    Any help would be appriciated.

    Thanks,

  2. #2
    Banned
    Join Date
    Sep 2001
    Posts
    852
    yes its a function called include()

    so u just at the top of the page usually put
    include(filename.inc);

    hope it helps rioter

  3. #3
    Member
    Join Date
    Jun 2002
    Posts
    95
    Thanks RiOtEr, i'm just checking now....

  4. #4
    Member
    Join Date
    Jun 2002
    Posts
    95
    does the file have to have an extention of '.inc'?

  5. #5
    Senior Member
    Join Date
    Jul 2002
    Posts
    154
    No, you can have any extension you want, .inc is just a good idea to keep yourself organized. You may also want to use the require() fuction, which for something can work better and can be more suited to your needs than include() can.

  6. #6
    Senior Member
    Join Date
    Oct 2001
    Posts
    677
    You can also use require_once('file.inc');

    or require_once('file.php');

    Options:
    include('file.php/inc');
    require('file.php/inc');
    require_once('file.php/inc');
    One Ring to rule them all, One Ring to find them.
    One Ring to bring them all and in the darkness bind them.
    (The Lord Of The Rings)
    http://www.bytekill.net

  7. #7
    Hi mom!
    Join Date
    Aug 2001
    Posts
    1,103
    Hmm, does this execute all code in that file, or does it just make functions and variables available?
    I wish to express my gratitude to the people of Italy. Thank you for inventing pizza.

  8. #8
    Banned
    Join Date
    Sep 2001
    Posts
    852
    guus include makes them avalible require runs it least thats my understanding of it
    rioter

  9. #9
    They both do the same thing, but the difference is that include will include whatever you want in the page and if there is an error it will continue loading the page. However require will stop the page from loading if there is an error. As for require and include once, they are usually used for files that you want to make sure aren't loaded multiple times, it is also helpful because it can keep you from making a mistake. Hope dis helps.

  10. #10
    Banned
    Join Date
    Oct 2001
    Posts
    1,459
    If you need to see any errors form the include use

    error_reporting(E_ALL);

    at the top of the page....

Posting Permissions

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