How can one handle email validation in PHP4 when filter_var is not available?

In PHP4, the filter_var function is not available for email validation. One way to handle email validation in PHP4 is to use regular expressions to check the email format. This can be done by creating a regular expression pattern that matches a valid email address format and then using the preg_match function to validate the email input.

$email = "example@example.com";

// Regular expression pattern for email validation
$email_pattern = "/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/";

// Check if the email input matches the pattern
if (preg_match($email_pattern, $email)) {
    echo "Email is valid";
} else {
    echo "Email is invalid";
}