Skip to content

Instantly share code, notes, and snippets.

@nellytadi
Created April 25, 2019 18:12
Show Gist options
  • Save nellytadi/8f6f2403b06d49308547d29e0c0c23a6 to your computer and use it in GitHub Desktop.
Save nellytadi/8f6f2403b06d49308547d29e0c0c23a6 to your computer and use it in GitHub Desktop.
<?php
$email='john@example.com';
public function validate($email)
{
// Initialize CURL:
$ch = curl_init('http://apilayer.net/api/check?access_key='.$access_key.'&email='.$email.'');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Store the data:
$json = curl_exec($ch);
curl_close($ch);
// Decode JSON response:
$validationResult = json_decode($json, true);
checkfunction($validationResult['format_valid']);
}
//function to check validation function
public function checkfunction($email){
if ($email==false) {
die('Wrong email');
}
else{
echo 'Valid email';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment