Kishan Kumar
What is the difference between include(), include_once() and require_once()
By Kishan Kumar in PHP on Feb 19 2018
  • Kishan Kumar
    Feb, 2018 19

    The include() statement includes and evaluates a specified line i.e. it will include a file based in the given path. require() does the same thing expect upon failure it will generate a fatal error and halt the script whereas include() will just gives a warning and allow script to continue. require_once() will check if the file already has been included and if so it will not include the file again.

    • 1
  • Roshan Rathod
    Jul, 2020 19

    include() function is not able to find a specified file on location at that time it will throw a warning message however, it will not stop script execution.

    include_once() If the code from a file has been already included then it will not be added again if we use include_once().

    require_once() the code from a php file has been already included then it will not be included again if we use require_once(). It implies require_once() will add the file just once at a time. If it can’t locate a specified file, at that time it will generate a fatal error but it will stop the content execution.

    • 0
  • Velu D
    Jul, 2019 4

    Include Once The include_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.

    • 0
  • Abhijit Sahoo
    Jul, 2018 4

    The only difference between the two is that require and its sister require_once throw a fatal error if the file is not found, whereas include and include_once only show a warning and continue to load the rest of the page.

    • 0

Most Popular Job Functions


var $j = jQuery.noConflict();