How can duplicate code be avoided in PHP scripts, such as including the same file multiple times?

Duplicate code can be avoided in PHP scripts by using the include_once() or require_once() functions to include files. These functions ensure that a file is only included once, preventing duplicate code execution. By using these functions, you can organize your code into separate files and include them when needed without worrying about duplication.

<?php
// Include the file only once
include_once('common.php');
?>