$email = 'example@example.com'; if(filter_var($email, FILTER_VALIDATE_EMAIL)){ echo "Email is valid"; } else { echo "Email is not valid"; }
$phone_number = '1234567890'; if(preg_match("/^\d{10}$/", $phone_number)){ echo "Phone number is valid"; } else { echo "Phone number is not valid"; }Package/Library: The package/library used for PHP validation varies depending on the type of data you want to validate. For example, for validating emails, you can use PHP's built-in filter_var() function. For validation of other data types such as URL, phone number or date, you can use third-party libraries like Respect\Validation or Symfony Validation Component.