Bug #1495: substr gets confused when used with strlen is the best way I can describe it.
| From: | richard at vasquez dot net | Date: | Sat, 05 Jun 1999 19:46:57 +0000 |
| Subject: | Bug #1495: substr gets confused when used with strlen is the best way I can describe it. | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-6586@lists.php.net to get a copy of this message | ||
From: richard@vasquez.net
Operating system: Linux
PHP version: 3.0.6
PHP Bug Type: Parser error
Bug description: substr gets confused when used with strlen is the best way I can describe it.
Here's a script that reproduces the problem. The first output shows the bug, as far as I can
see. The second output shows how it should be. If you look at the output, the problem only occurs
during the first few numbers in a sequence which makes me think it's a bug. ie, 0, 1, 2 come
out as 00, 01, 02, while 3 on up (until 100, where the bug reoccurs) come out as 003, etc.
The only modules I have configured in are gd and mysql. PHP is running as an Apache (1.3.3) module.
<?
for($loop=0; $loop <110; $loop++)
{
$tmpidx="000$loop";
$orig=$tmpidx;
$tmpidx=substr($tmpidx, strlen($tmpidx-3), 3);
echo "$loop: $tmpidx ($orig)<BR>\n";
}
?>
<HR>
<?
for ($loop=0; $loop <110; $loop++)
{
$tmpidx="00$loop";
$orig=$tmpidx;
$tmplen=strlen($tmpidx)-3;
$tmpidx=substr($tmpidx, $tmplen, 3);
echo "$loop: $tmpidx ($orig)<BR>\n";
}
?>