Create a script in PHP to validate an email address
Create a script in PHP to validate an email address
回复样本
Here's a simple PHP script to validate an email address:
```
<?php
$email = "example@example.com"; // Replace with the email to be validated
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "Valid email";
} else {
echo "Invalid email";
}
?>
```
This script uses the `filter_var()` function in PHP along with the `FILTER_VALIDATE_EMAIL` filter to check if the email is valid. If it's valid, the script will output "Valid email". Otherwise, it will output "Invalid email".
出版日期:
1 年前