php header own url+?error=etc

So are you can read in the titel i need some command or some line that can do this for me:

header("location: ".$_SERVER['PHP_SELF'].?error=fag"");

So what i mean is that normally it would be

header('Location: index.php?error=fag');

But i want to replace index.php with a line/command that will retrieve the current pageurl and ads that to ?error=fag

I tried to look this up and came with this cmd $_SERVER['PHP_SELF']

But it wont work atleast not how i did it in the first line.

<?
if(help) {
you get chick
} else
{
dont rply
}
?>
Comments
5
Please mind the typo at least...
i could help but i wont because you keep spamming me on irc
do not help this spammer fag!
obviously it wont work in way you wrote it, at least not in full scope. Imagine you have link "index.php?content=gallery&page=3", you cant just append "?error=fag" at the end. The only thing you need is to check whether you have additional arguments part present in your url or not (I guess its enough to check if question mark is present in url string). If you have link with named arguments passed, you will append "&error=fag" at the end, if you dont have you need to append "?error=fag". In case you want to replace argument part with "?error=fag", you will just need to disconnect argument part from url string (everthing after "?", questionmark included) and append there what you need.
header("Location: " . $_SERVER['PHP_SELF'] . "?error=fag");
Back to top