What are some best practices for combining multiple validation conditions in PHP, such as for host or IP address validation?

When combining multiple validation conditions in PHP, such as for host or IP address validation, it is best to use logical operators like && (AND) or || (OR) to check each condition. This allows you to create more complex validation rules that require multiple conditions to be met. By using these logical operators, you can ensure that your validation logic is both efficient and accurate.

// Example of combining host and IP address validation in PHP
$host = "example.com";
$ip = "192.168.1.1";

if (filter_var($host, FILTER_VALIDATE_DOMAIN) && filter_var($ip, FILTER_VALIDATE_IP)) {
    echo "Both host and IP address are valid.";
} else {
    echo "Either host or IP address is invalid.";
}