What is the difference between require and require_once in PHP?

The main difference between require and require_once in PHP is how they handle file inclusions. When using require, the included file will be included each time the require statement is executed. This means that if the same file is required multiple times in a script, it will be included each time. On the other hand, require_once will check if the file has already been included and will not include it again if it has. This can be useful to prevent errors that may occur when including the same file multiple times.

// Using require
require 'file.php';
require 'file.php'; // file.php will be included again

// Using require_once
require_once 'file.php';
require_once 'file.php'; // file.php will not be included again