What are the best practices for organizing PHP code to ensure smooth functionality across different hosts?

When organizing PHP code to ensure smooth functionality across different hosts, it is important to follow best practices such as using relative paths instead of absolute paths for includes and requires, avoiding server-specific configurations, and using standardized PHP functions and syntax. This will help prevent issues related to file paths, server configurations, and PHP versions.

// Example of using relative paths for includes
include_once(dirname(__FILE__) . '/includes/config.php');

// Example of avoiding server-specific configurations
$db_host = 'localhost';
$db_user = 'username';
$db_pass = 'password';
$db_name = 'database_name';

// Example of using standardized PHP functions and syntax
$query = "SELECT * FROM users WHERE id = :id";
$stmt = $pdo->prepare($query);
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
$stmt->execute();