I was wondering how can I convert the code below into a PHP function that works.
Here is my original code.
if(isset($_GET['cat'])) {
$cat_name = strip_tags(filter_var($_GET['cat'], FILTER_SANITIZE_URL));
}
So far I got this for the function.
function cat(){
if(isset($_GET['cat'])) {
$cat_name = strip_tags(filter_var($_GET['cat'], FILTER_SANITIZE_URL));
}
}
This will return the sanitized value or
nullif$_GET['cat']is not set. When you call this function, you would need to check if the return value isnull.