What is the purpose of using the include function in PHP and what potential pitfalls should be considered when implementing it?
The purpose of using the include function in PHP is to include and execute the specified file within the current script. This allows for code reuse and modularity by breaking up large scripts into smaller, more manageable files. When implementing the include function, it is important to consider potential pitfalls such as file path vulnerabilities, including sensitive files, and causing naming conflicts.
// Example of using include function in PHP
include 'header.php';
include 'content.php';
include 'footer.php';