Header function problems with filter_input function

I have noticed that Netbeans has told me that I can’t access superglobal directly, this therefore requires me to change this piece of script

    header('Location: ' . $_SERVER['SCRIPT_NAME'], true); 

To something that doesn’t use the $_SERVER superglobal array directly, would anyone please tell me how I can do this? I have searched for this using google, but there isn’t really a good solution to what I need

It’s just a warning from NetBeans that the $_SERVER super global (along with other super globals like $_POST, $_GET, $_COOKIE, etc) are potentially tainted, and so it advises you to sanitise them first before directly using them. You can either put up with the warning (provided you know how to handle potentially tainted data), or you can sanitise the data first with the filter_input() function. In your case above, you could rewrite it as follows:

$scriptName = filter_input(INPUT_SERVER, 'SCRIPT_NAME', FILTER_SANITIZE_STRING);
header('Location: ' . $scriptName, true);

OK, thank you for that, it worked @tpunt