PHP 4.0 Bug #6174: problem with sprintf, urlencode and string concatenation

From: Date: Tue, 15 Aug 2000 16:31:32 +0000
Subject: PHP 4.0 Bug #6174: problem with sprintf, urlencode and string concatenation
Groups: php.dev 
Request: Send a blank email to php-dev+get-28995@lists.php.net to get a copy of this message
From: johnw@cogs.susx.ac.uk Operating system: Solaris 7 PHP version: 4.0.1pl2 PHP Bug Type: Misbehaving function Bug description: problem with sprintf, urlencode and string concatenation The following script: <? function add_query_string($url, $qs) { return "$url?$qs"; } function url_stem() { return add_query_string("test.php", "arg1=foo"); } function test() { for ($i=0; $i < 10; $i++) { $url=url_stem() . sprintf("&arg2=%s", urlencode("baz")); print("$i - $url<BR>\n"); } } test(); ?> fails on ALTERNATE times round the loop, i.e. it produces the output: 0 - test.php?arg1=foo&arg2=baz 1 - 2 - test.php?arg1=foo&arg2=baz 3 - 4 - test.php?arg1=foo&arg2=baz 5 - 6 - test.php?arg1=foo&arg2=baz 7 - 8 - test.php?arg1=foo&arg2=baz 9 - I've boiled this down as much as I can (which is why the code might look a bit silly). PHP is statically linked into Apache 1.3.4 running on a Sun Ultra 1.

« previous php.dev (#28995) next »