What is the purpose of the require_once function in PHP and how does it affect code execution?

The require_once function in PHP is used to include and evaluate a specified file during the execution of a script. It ensures that the file is included only once, preventing multiple inclusions and potential conflicts. This function is commonly used to include files that contain functions, classes, or configurations needed for the script to run correctly.

require_once 'config.php';
require_once 'functions.php';
// Rest of the code that depends on the included files