1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Difference between require, require_once, and include?

Discussion in 'PHP' started by ignas2526, Sep 12, 2008.

  1. #1
    Hello,
    what difference between them?
    Thanks.
     
    ignas2526, Sep 12, 2008 IP
  2. allaboutgeo

    allaboutgeo Peon

    Messages:
    85
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The require_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the require() statement, with the only difference being that if the code from a file has already been included, it will not be included again.
     
    allaboutgeo, Sep 12, 2008 IP
  3. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #3
    require, require_once will throw an error if the file required is not found but include just throw a warning.
     
    mwasif, Sep 12, 2008 IP
  4. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #4
    require - File must be included or the script will exit with a fatal error
    require_once - Same as above, except it can only be included once

    include - same as require, except script will continue if the file is not found, and only produce a warning
    include_once - same as require_once except script will continue if the file is not found and only produce a warning

    Click on the links above for more information about each. That is what the manual is there for ;)
     
    JAY6390, Sep 12, 2008 IP