Yes, thanks John, with a little tweaking this does just what I needed. I keep forgetting to use that compact conditional syntax, it's sexy.
I had to use PHP_SELF instead of REQUEST_URI first, since the latter contains the path, the script, and the query string. $url = $_SERVER['PHP_SELF'] . '?' . @$_SERVER['QUERY_STRING'] . '&newVar=1'; Now I can just throw in a conditional like below to make sure I'm not duplicating the newVar in my query string. Thanks! -- Matt Grimm ----- Original Message ----- From: "CPT John W. Holmes" <[EMAIL PROTECTED]> To: "Matt Grimm" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Wednesday, May 28, 2003 1:06 PM Subject: Re: [PHP] Appending to the REQUEST_URI > Replying to myself... :) > > > You have to check for it, regardless. See if this works for you. > > > > $url = $_SERVER['REQUEST_URI'] . '?' . ((isset($_SERVER['QUERY_STRING'])) > ? > > $_SERVER['QUERY_STRING'] . '&' : '' ) . 'newVar=1'; > > > > The middle part basically sees if the QUERY_STRING is empty. If it is, it > > includes a question mark otherwise it includes an apersand. Actually, to > be > > fully compliant, replace the & with & in your URLs. > > I changed the code and forgot to fix the above paragraph. The middle part > sees if QUERY_STRING is set, if it is, it includes it's value and appends an > ampersand to the end, then includes the new var. The question mark has to be > included no matter what, since it's not a part of the query string variable. > > Actually, the easiest way would just be to use: > > $url = $_SERVER['REQUEST_URI'] . '?' . @$_SERVER['QUERY_STRING'] . > '&newVar=1'; > > The @ will suppress any warnings about undefined index. You may end up with > www.domain.com?&newVar=1, but it'll still work. Don't know if it's > "compliant" or what... but.... :) > > ---John Holmes... > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php