What best practices should be followed when including files in PHP to prevent security vulnerabilities?

When including files in PHP, it is important to follow best practices to prevent security vulnerabilities such as remote code execution or directory traversal attacks. One way to mitigate these risks is by using absolute paths instead of relative paths when including files. This helps to ensure that only intended files are included and prevents attackers from manipulating the file path to include malicious files.

include_once(__DIR__ . '/path/to/file.php');