top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

What is the difference between require_once and require in PHP?

0 votes
What is the difference between require_once and require in PHP?
posted Dec 23, 2017 by Jdk

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

0 votes

The require() function is identical to include(), except that it handles errors differently. If an error occurs, the include() function generates a warning, but the script will continue execution. The require() generates a fatal error, and the script will stop.

The require_once() statement is identical to require() except PHP will check if the file has already been included, and if so, not include (require) it again.

answer Dec 26, 2017 by Madhavi Latha
0 votes

The require statement has two variations, require and require_once.

The require/require_once statement is used to include file.

Require_once is ignored if the required file has already been added by any of the four include statements.
It has the following syntax:

require 'file_name';

require_once 'file_name';
answer Aug 14 by Siddhi Patel
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.