Re: New function proposal urlappendvar()

From: Date: Wed, 21 Jan 2004 14:04:40 +0000
Subject: Re: New function proposal urlappendvar()
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-7247@lists.php.net to get a copy of this message
I agree with Rasmus, I don´t believe that it is necessary to add a new function that can be solved with a simple line in PHP, another thing would be to be able to make the function your same one and to add it to your PHP. You can add into ext/standard/string.c your function. Iván Rodriguez Espada _________________________ ALAPLAYA.COM http://www.alaplaya.com epplestun@alaplaya.com ----- Original Message ----- From: "Rasmus Lerdorf" <rasmus@php.net> To: "Juan Alonso" <jalonso@art3mis.com> Cc: <internals@lists.php.net> Sent: Wednesday, January 21, 2004 12:31 PM Subject: Re: [PHP-DEV] New function proposal urlappendvar() > Generally we don't add functions to replace simple one-line PHP > expressions. > > $url .= strstr($url,'?')?"?foo=$foo":"&foo=$foo"; > > -Rasmus > > On Wed, 21 Jan 2004, Juan Alonso wrote: > > > Hello list, > > > > I find often myself wanting to append a variable to an unknown url. The > > problem is that you don't know if you should append the var with ? or > > with &. Do you think it would be useful to have a builtin function that > > would do this automatically? > > > > example code as I do it actually: > > <?php > > $foo = mt_rand(); > > $separator = (ereg('?', $_SERVER['HTTP_REFERER'])) ? '&' > > : '?'; > > $url = $_SERVER['HTTP_REFERER'].$separator.'foo='.$foo; > > ?> > > > > > > example code with the new version: > > <?php > > $foo = mt_rand(); > > $url = urlappendvar($_SERVER['HTTP_REFERER'], 'foo', $foo); > > ?> > > > > > > I use it quite frequently so I thought it could be useful to have such > > functionality builtin. > > > > What do you think? > > > > -- > > Juan Alonso Hernández > > Desarrollo, Seguridad y Sistemas > > > > www.art3mis.com | (34) 91 530 16 33 > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.internals (#7247) next »