Skip to content

Instantly share code, notes, and snippets.

@cam-gists
Created July 2, 2012 21:15
Show Gist options
  • Save cam-gists/3035738 to your computer and use it in GitHub Desktop.
Save cam-gists/3035738 to your computer and use it in GitHub Desktop.
PHP: Validate Vars
<?php
// Check Range of Value
$value = filter_input(INPUT_GET, "value", FILTER_VALIDATE_INT,
array("options" => array("min_range" => 15, "max_range" => 20)));
if ($value) {
// run my code
}
else {
// handle the issue
}
// Validate Email
$email = filter_var($email, FILTER_VALIDATE_EMAIL);
if ($email !== false) {
mail($email, "Here is my email", "Some Content");
}
else {
// handle the issue invalid email address
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment