Skip to content

Instantly share code, notes, and snippets.

@GabeStah
Created December 9, 2015 06:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GabeStah/4985e41fa7ad86a62f20 to your computer and use it in GitHub Desktop.
Save GabeStah/4985e41fa7ad86a62f20 to your computer and use it in GitHub Desktop.
Coding Dojo - PHP Best Practices - Simple Validation
<?php
// Returns 'john.doe@gmail.com', a valid email.
echo filter_var("john.doe@gmail.com", FILTER_VALIDATE_EMAIL), '<br/>';
// Return 'http://www.codingdojo.com/', a valid URL.
echo filter_var("http://www.codingdojo.com/", FILTER_VALIDATE_URL), '<br/>';
// Return '192.168.0.0', a valid IP.
echo filter_var("192.168.0.0", FILTER_VALIDATE_IP), '<br/>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment