#27452 [NEW]: 0 typed to NULL causes indexing error

From: Date: Mon, 01 Mar 2004 22:38:24 +0000
Subject: #27452 [NEW]: 0 typed to NULL causes indexing error
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-55749@lists.php.net to get a copy of this message
From: Er1c at comcast dot net Operating system: WinXP PHP version: 5.0.0b4 (beta4) PHP Bug Type: Scripting Engine problem Bug description: 0 typed to NULL causes indexing error Description: ------------ When a variable's type is "NULL" (as reported by var_dump()) which happens when the variable is set to 0, it can no longer be used to access the 0th position in an array. In my perticular case, I was attempting this operation: return $this->serverdata[$this->dataindex][$var]; and needed to do this to get it to run correctly: return $this->serverdata[intval($this->dataindex)][$var]; I have not throughly tested this bug for other cases where it occurs, but this is definatly one of the cases. Reproduce code: --------------- class testing { private $dataindex; private $serverdata; function __construct() { $dataindex = 0; $serverdata = array(array("name"=>"Er1c","data"=>"foo"),array("name"=>"Bob","data"=>"bar")); } function __get($var) { return $this->serverdata[$this->dataindex][$var]; } } $blah = new testing(); echo "Name:" . $blah->name; Expected result: ---------------- Name: Er1c Actual result: -------------- Name: -- Edit bug report at http://bugs.php.net/?id=27452&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27452&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27452&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=27452&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=27452&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=27452&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=27452&r=needscript Try newer version: http://bugs.php.net/fix.php?id=27452&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=27452&r=support Expected behavior: http://bugs.php.net/fix.php?id=27452&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=27452&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=27452&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=27452&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27452&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=27452&r=dst IIS Stability: http://bugs.php.net/fix.php?id=27452&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=27452&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=27452&r=float

« previous php.bugs (#55749) next »