In a link you can append get parameters. If I want to add a new get parameter to a url which already has one.
Example:
old: example.php?hi=hello
new: example.php?hi=hello&hello=hi
Is there any other way of doing it this way:
echo '<a href="'. $_SERVER['REQUEST_URI'].'&hello=hi">';
The caveat is detecting whether or not the question mark exists or not. If it doesn’t, you’ll need to add it. A quick and dirty way would be strpos:
A more robust method would be breaking down the
REQUEST_URIand rebuilding it after inspection using parse_url and http_build_query but that may be beyond the scope.