What are the advantages and disadvantages of using PHP include or require functions to include external files in PHP scripts?

When including external files in PHP scripts, using the include or require functions can be advantageous as it allows you to reuse code across multiple files, making your code more modular and easier to maintain. However, using these functions can also pose security risks if the included file is not properly sanitized, potentially exposing your application to vulnerabilities.

<?php
// Using require_once to include an external file
require_once 'external_file.php';

// Using include_once to include another external file
include_once 'another_external_file.php';
?>