What are the advantages and disadvantages of including a logout script via "include" in PHP compared to other methods?

Including a logout script via "include" in PHP can make the code more modular and easier to maintain. It allows for reusing the same logout functionality across multiple pages without duplicating code. However, it may also introduce security risks if the included file is not properly secured or if sensitive information is exposed.

<?php
// logout.php
session_start();
unset($_SESSION['user_id']);
session_destroy();
header("Location: index.php");
exit;
?>

<?php
// logout_button.php
include 'logout.php';
?>