1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Dear Visitor, we are presently having a membership drive and as a result EVERY new member that registers an account and makes THREE meaningful posts will have a mighty $10,000$ forum credits added to their wallets ... GET YOURS NOW!
    Dismiss Notice
  3. IMSpot.Org is under new management and we look forward to bringing you a range of exciting enhancements in coming days.
    Dismiss Notice
  4. Dear Visitors, why not register an account now and say hello ... we really would love to hear from you?
    Dismiss Notice
  5. Welcome to IMSpot.Org an internet marketing forum and very friendly place for discussion, learning and help in your online endeavours ... please consider joining our internet marketing community and sharing your knowledge with our members.
    Dismiss Notice

difference between include and require?

Discussion in 'PHP' started by rascal, Dec 15, 2011.

  1. rascal

    rascal Guest

    Joined:
    Messages:
    0
    Likes Received:
    0
    I know that include can return value and the require cant.is there any other difference between them?
     
  2. messi

    messi Guest

    Joined:
    Messages:
    0
    Likes Received:
    0
    The difference is that if we use require_once() then the file to be added should exist in the given path,if not it will display a fatal error.if we use a include_once there will be no more problem due to this ,if there exist no such file.if we need to include a file then we will prefer include_once() because it will include the file once,it willnot include the file if it is inluded earlier
     
  3. semaphore.v

    semaphore.v An Active Forum Member

    Joined:
    Aug 9, 2013
    Messages:
    88
    Likes Received:
    0
    The include() function generates a warning (which does not halt execution) while the require() function generates a fatal error (which stops execution immediately).
     
  4. Williams Brown

    Williams Brown A Recent Forum Member

    Joined:
    Dec 2, 2013
    Messages:
    2
    Likes Received:
    0
    Yes, I agree with the difference between include and require. This is the function which is not required to have halt execution and require is the one that stops execution immediately.
     
  5. Denise Davidson

    Denise Davidson Moderator
    Staff Member IMSpot Coder

    Joined:
    Dec 14, 2016
    Messages:
    1
    Likes Received:
    1
    Use include if you don't mind your script continuing without loading the file (in case it doesn't exist etc) and you can (although you shouldn't) live with a Warning error message being displayed.
    Using require means your script will halt if it can't load the specified file, and throw a Fatal error.
     
    PassingThrough likes this.
Loading...
Live Thread addon by sonnb

Share This Page