PHP 4.0 Bug #5688: Unset() inconsistent treatment of resource values not as integers
| From: | mlemos at acm dot org | Date: | Thu, 20 Jul 2000 04:30:59 +0000 |
| Subject: | PHP 4.0 Bug #5688: Unset() inconsistent treatment of resource values not as integers | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-25176@lists.php.net to get a copy of this message | ||
From: mlemos@acm.org
Operating system: Linux RH 6
PHP version: 4.0.0
PHP Bug Type: Misbehaving function
Bug description: Unset() inconsistent treatment of resource values not as integers
Resource values like those returned by ImageCreate() are integers, despite when
they are echo'ed they expand to something like "Resource id #nnn".
However, it seems that when a resource value is used and array index,
Unset() does not take it as an integer unless you explicitly cast the
value. Try this script to see the problem.
<?
$resource=ImageCreate(1,1);
$array=array();
$array[$resource]=1;
Unset($array[$resource]);
echo IsSet($array[$resource])," ",serialize($array)," ",$resource,"
",intval($resource),"\n";
Unset($array[intval($resource)]);
echo IsSet($array[$resource])," ",serialize($array)," ",$resource,"
",intval($resource),"\n";
?>