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



Reply via email to