I am writing a function in php for blocking some urls like Scam & Fraud or profanity. It should be act like a filter or validation rule. I am just confusing which variable is best for this purpose.
1. trim()
2. strippos ()
or do you have any better solutions then this .?
Function would be like this
function validation($data) {
$data = trim(https://www.url.com, https://www.url1.com ...);
return data;
}
OR
function validation($data) {
$data = stripos(https://www.url.com, https://www.url1.com ...);
return data;
}
That ain't gonna work. I'd list all the url's you want to check in an array and search in there;
function is_url_allowed($url) {
$not_allowed = array(
'google.com',
'facebook.com',
'usa.gov'
);
$parsed_url = parse_url($url, PHP_URL_HOST);
return !in_array($parsed_url, $not_allowed);
}