New function proposal urlappendvar()
| From: | Juan Alonso | Date: | Wed, 21 Jan 2004 11:17:46 +0000 |
| Subject: | New function proposal urlappendvar() | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-7227@lists.php.net to get a copy of this message | ||
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