PHP FILTER SECURITY EXAMPLES
Page 1 of 1
PHP FILTER SECURITY EXAMPLES
- Code:
<?php
// ?url=
if(isset($_GET['url'])) {
$url = preg_replace('#[^a-z0-9]#i', '', $_GET['url']);
}
?>
<?php
$url = "http://www.w3schools.com";
// Remove all illegal characters from a url
$url = filter_var($url, FILTER_SANITIZE_URL);
// Validate url
if (!filter_var($url, FILTER_VALIDATE_URL) === false) {
echo("$url is a valid URL");
} else {
echo("$url is not a valid URL");
}
?>
http://www.w3schools.com/php/php_filter.asp
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|