---
title: "What is difference between require_once(), require(), include()?"  
description: "What is difference between require_once(), require(), include()?"  
author: "Rajesh Goswami"  
published: 2010-11-25  
updated: 2020-09-24  
canonical: https://www.mindstick.com/interview/265/what-is-difference-between-require_once-require-include  
category: "java"  
tags: ["java"]  
reading_time: 2 minutes  

---

# What is difference between require_once(), require(), include()?

These three function usely use to call a file in another file?\
\
**Difference between require() and require_once():**\
require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page). So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don't include the file more times and you will not get the "function re-declared" error. \
**Difference between require() and include()** is that require() produces a FATAL ERROR if the file you want to include is not found, while include() only produces a WARNING. There is also include_once() which is the same as include(), but the difference between them is the same as the difference between require() and require_once().

## Answers

### Answer by Rajesh Goswami

These three function usely use to call a file in another file?\
\
**Difference between require() and require_once():**\
require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page). So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don't include the file more times and you will not get the "function re-declared" error. \
**Difference between require() and include()** is that require() produces a FATAL ERROR if the file you want to include is not found, while include() only produces a WARNING. There is also include_once() which is the same as include(), but the difference between them is the same as the difference between require() and require_once().


---

Original Source: https://www.mindstick.com/interview/265/what-is-difference-between-require_once-require-include

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
