I learned recently that I can use basename($_SERVER['SCRIPT_NAME']) to extract the current file name. I use it, with some other code, to offer better navigation links. I now need to modify my script so that I can extract the current file name and the info I'm passing through the URL. So, instead of extracting just myscript.php, I now need to identify myscript.php?info=general. Can you tell me how to modify basename($_SERVER['SCRIPT_NAME']) so that it also extracts the name/value pair that gets passed through the URL? Thank you for your time.
basename($_SERVER['REQUEST_URI']); // just in case thats URi not URL :) PHP: which gives you the myscript.php?info=general
Hi! Run This Query And Choose Your Server Variable Which U Want To Use. <?PHP foreach($_SERVER as $key_name => $key_value) { print $key_name . " = " . $key_value . "<br>"; } ?>
You'd have to use the $_SERVER['REQUEST_URI'] variable instead - as previously suggested by MyVodaFone. You may also find useful the parse_str() function.